Results 1 to 5 of 5
  1. #1
    kickserve is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Unable to compile/run java on the command line...but it works fine in eclipse

    I have been using eclipse to create java programs for over a year, but a class I am taking now requires that we use the command line to compile and run our code. For some reason, when I try to compile code it tells me:

    'javac.exe' is not recognized as an internal or external command, operable program or batch file.

    I have looked at several posts on this topic, and so I assume that there is probably a problem with my PATH variable..but I was unable to fix the problem

    my path is:
    bin;C:\Program Files (x86)\Haskell Platform\2011.4.0.0\lib\extralibs\bin;C:\Program Files (x86)\Haskell Platform\2011.4.0.0\bin;%CommonProgramFiles%\Micro soft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoo t%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowe rShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\jdk1.6.0_21\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\ruby-1.9.3\bin;C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd;C:\Dwimperl\perl\bin;C:\Dwimperl\per l\site\bin;C:\Dwimperl\c\bin;C:\strawberryperl\c\b in;C:\strawberryperl\perl\site\bin;C:\strawberrype rl\perl\bin

    As you may be able to tell...I also had some trouble installing perl...I should probably clean that up.
    The path to my jdk bin is correct, javac should be there.

    It isn't something I messed up recently, I can still use eclipse to compile and run my programs with no problems.
    I'm lost, and I don't know much about what system variable are or what they mean, so I am hesitant to jump in and mess around with them. I followed precise instructions to install java, and haven't touched it since (Although it seems to have been automatically changed when I installed perl, haskell, etc.) Does anyone know what the problem is?
    Last edited by kickserve; 04-06-2012 at 08:19 AM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Unable to compile/run java on the command line...but it works fine in eclipse

    Can you confirm that you got this path by typing

    Java Code:
    path
    at the command line (terminal)? Or say how you know this is the path. (*)

    Also can you confirm that javac.exe is where it should be, with the following commands:

    Java Code:
    "C:\Program Files\jdk1.6.0_21\bin\javac.exe" -version
    dir "C:\Program Files\jdk1.6.0_21\bin\java*.exe"
    [Edit] * In fact it would be a good idea to copy and post the exact and entire output obtained from executing the path command.

  3. #3
    kickserve is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: Unable to compile/run java on the command line...but it works fine in eclipse

    I found the path by going to computer -> properties -> advanced system settings -> environment variables. By typing path in the terminal I get:

    C:\Users\David Curtis>path
    PATH=bin;C:\Program Files (x86)\Haskell Platform\2011.4.0.0\lib\extralibs\bin;C:
    \Program Files (x86)\Haskell Platform\2011.4.0.0\bin;%CommonProgramFiles%\Micro s
    oft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\Sys tem32\Wbem;
    C:\windows\System32\WindowsPowerShell\v1.0\;C:\Pro gram Files (x86)\ATI Technolog
    ies\ATI.ACE\Core-Static;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Fi
    les\jdk1.6.0_21\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Hero
    ku\bin;C:\Program Files (x86)\ruby-1.9.3\bin;C:\Program Files (x86)\git\bin;C:\P
    rogram Files (x86)\git\cmd;C:\Dwimperl\perl\bin;C:\Dwimperl\per l\site\bin;C:\Dwi
    mperl\c\bin;C:\strawberryperl\c\bin;C:\strawberryp erl\perl\site\bin;C:\strawberr
    yperl\perl\bin;C:\Users\David Curtis\AppData\Roaming\cabal\bin

    which seems pretty similar to what I had originally, but with a bit extra.

    Version works correctly (I think):
    C:\Users\David Curtis>"C:\Program Files\jdk1.6.0_21\bin\javac.exe" -version
    javac 1.6.0_21

    C:\Users\David Curtis>dir "C:\Program Files\jdk1.6.0_21\bin\java*.exe"
    Volume in drive C has no label.
    Volume Serial Number is some hexadecimal number

    Directory of C:\Program Files\jdk1.6.0_21\bin

    09/23/2010 07:50 PM 32,256 java-rmi.exe
    09/23/2010 07:50 PM 165,888 java.exe
    09/23/2010 07:50 PM 33,792 javac.exe
    09/23/2010 07:50 PM 33,792 javadoc.exe
    09/23/2010 07:50 PM 33,792 javah.exe
    09/23/2010 07:50 PM 33,792 javap.exe
    09/23/2010 07:50 PM 165,888 javaw.exe
    09/23/2010 07:50 PM 183,296 javaws.exe
    8 File(s) 682,496 bytes
    0 Dir(s) 60,632,526,848 bytes free

    Everything looks to be in order to me, but I don't know what to look for I suppose.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Unable to compile/run java on the command line...but it works fine in eclipse

    Looks fine to me, too. (The reason why there is more stuff shown in the path is that some is system wide and some is per-user).

    At least you should be able to compile now: by using "C:\Program Files\jdk1.6.0_21\bin\javac.exe" in place of javac. But it's a pain to have to type that. Perhaps someone else can spot something. Your path is somewhat longer than mine and perhaps that is a problem.

  5. #5
    kickserve is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: Unable to compile/run java on the command line...but it works fine in eclipse

    Thanks! I'll try experimenting with the path, although I doubt the time I spend doing that will be less than the time it takes to type some extra characters. pbrockway2, you are my hero.

Similar Threads

  1. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  2. Replies: 3
    Last Post: 04-15-2010, 03:41 AM
  3. [SOLVED] Compile from the command line
    By GilaMonster in forum New To Java
    Replies: 8
    Last Post: 06-13-2008, 08:12 AM
  4. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:23 AM
  5. Java Command Line Arguments In Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-19-2007, 10:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •