Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: A problem with command line compilation

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    21
    My Mood
    Sleepy
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default A problem with command line compilation

    Hey Everyone who reads this.

    I'm kind of new to Java, and right now I'm learning nuts and bolts of compilation and running apps process.
    So here's the problem. I have JRE and jdk1.6.0_20 installed, I have Eclipse which runs perfectly, all other programs depending on Java (like FlashDevelop, OpenOffice and a couple of others) also work great.
    I wrote a simple Java application in Eclipse (which basically just prints out "Hello World" line).
    Eclipse compiles and runs it with no problems, but when I wanna run it using the Windows command line, it gives me this:

    As you can see it finds my app and even estimates it's size unless it comes to running

    I've googled out a lot of similar problems, but none the exact, so I think it's time to post it here

    by the way, I have environment variable set up:


    And I'm sure JAVA_HOME works. But I'm not sure about JRE_HOME. I have jre installed into the same directory where I got Eclipse. But I altered it several time, and it didn't help.


    How can I solve this problem?

    Regards, Konstantin.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: A problem with command line compilation

    The command line for executing a jar file is:
    java -jar testApp.jar

    The -jar option has a leading -

    I don't know why the environment variables would be needed.

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

  3. The Following User Says Thank You to Norm For This Useful Post:

    goodguy (August 2nd, 2010)

  4. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    21
    My Mood
    Sleepy
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: A problem with command line compilation

    Thanks for the reply
    But dash before jar didn't help either.
    The problem's still there
    Microsoft Windows [Version 6.1.7600]
    (c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.

    C:\Users\Konstantin>cd \MyJava

    C:\MyJava>java -jar testApp.jar
    Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
    I don't know why the environment variables would be needed.
    I had a problem with path to jdk (which looked similar to this) when I first installed Eclipse, and adding environment variable solved that problem. I thought it may be the same sort of problem, but I was mistaken

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: A problem with command line compilation

    That looks like an installation problem. Perhaps the environment variables you've set has confused java.

    Here are my environment variables:
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    D:\Norms\Norms Tools>set
    ALLUSERSPROFILE=C:\Documents and Settings\All Users
    ANT_HOME=C:\Program Files\apache-ant-1.6.5
    APPDATA=C:\Documents and Settings\Owner\Application Data
    CATALINA_HOME=D:\Program Files\Apache Software Foundation\Tomcat 5.5
    CLASSPATH=D:\JavaDevelopment;.
    CLIENTNAME=Console
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=TIGERDIRECT
    ComSpec=C:\WINDOWS\system32\cmd.exe
    DEV_DRIVE=D:
    DEV_HOME=D:
    DOCS_HOME=C:
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Documents and Settings\Owner
    JAVA_HOME=C:\Program Files\Java\jdk1.5.0_04
    JAVA_RUN=D:\JavaDevelopment\runtime
    JDK_HOME=D:\Java\jdk1.6.0_02
    JMFHOME=E:\Java\JMF2.1.1e
    LOGONSERVER=\\TIGERDIRECT
    NUMBER_OF_PROCESSORS=1
    OS=Windows_NT
    Path=C:\Program Files\PHP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDO WS\System32\Wb
    em;C:\Program Files\Java\jdk1.5.0_04\bin;C:\BatchFiles;C:\Progra m Files\Support
    Tools\;C:\WINDOWS\system32\WindowsPowerShell\v1.0; C:\Program Files\QuickTime\QTS
    ystem\
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WS F;.WSH;.PSC1
    PHPRC=C:\Program Files\PHP\
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 15 Model 31 Stepping 0, AuthenticAMD
    PROCESSOR_LEVEL=15
    PROCESSOR_REVISION=1f00
    ProgramFiles=C:\Program Files
    PROMPT=$P$G
    QTJAVA=D:\Java\jre6_20\lib\ext\QTJava.zip
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\WINDOWS
    TEMP=C:\DOCUME~1\Owner\LOCALS~1\Temp
    TMP=C:\DOCUME~1\Owner\LOCALS~1\Temp
    TOMCAT_HOME=C:\Java\jakarta-tomcat-3.2.4
    USERDOMAIN=TIGERDIRECT
    USERNAME=Owner
    USERPROFILE=C:\Documents and Settings\Owner
    windir=C:\WINDOWS
    WORK_DIR=D:\JavaClass

    D:\Norms\Norms Tools>

  6. The Following User Says Thank You to Norm For This Useful Post:

    goodguy (August 2nd, 2010)

  7. #5
    Junior Member
    Join Date
    Jul 2010
    Posts
    21
    My Mood
    Sleepy
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: A problem with command line compilation

    When I first installed Java to Program Files, it worked fine. But then I've read a recommendation (in one book) to install it into the root directory of disk C. I thought I would be a piece of cake to reinstall everything but when I removed it, I found out it was very stupid of me to follow that recommendation. I killed a half a day to get everything up and running again. Now Java is installed in the root of disk C and it gives me more problems that conveniences.


    Anyways, I've created the directory manually and copied jre there. It helped me get rid of this problem for now. (Not sure if it's the best decision though)

    Thanks for trying to help

Similar Threads

  1. [SOLVED] Command Line Argument Help
    By EmSaint in forum Loops & Control Statements
    Replies: 2
    Last Post: January 28th, 2010, 10:55 AM
  2. Multi-Valued Command Line Arguments
    By joey86 in forum Java Theory & Questions
    Replies: 1
    Last Post: December 29th, 2009, 11:19 AM
  3. Replies: 6
    Last Post: April 29th, 2009, 09:35 AM
  4. How to Send command line arguments in Eclipse?
    By JavaPF in forum Java JDK & IDE Tutorials
    Replies: 0
    Last Post: April 23rd, 2009, 11:37 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM