aspose file tools*
The moose likes Beginning Java and the fly likes Problem with JDK at command prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with JDK at command prompt" Watch "Problem with JDK at command prompt" New topic
Author

Problem with JDK at command prompt

Anthony Della Rosa
Greenhorn

Joined: Mar 19, 2007
Posts: 12
I have installed the jdk to the c: drive on my pc
C:\Program Files\Java\jdk1.6.0\bin and have set the classpath under environment variables to .;C:\Program Files\Java\jdk1.6.0\bin

the program will not compile telling me that javac cannot be found yet I have the classpath set correctly.

Also when I use a TextPad my programs compile and run with no errors. How can that be? After I compile under TextPad I can run the program at the command prompt using the java command.


Any help will be greatl appreciated


- Mr. D
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11320
    
  16

you need to set you PATH to include the jdk/bin directory, not the CLASSPATH.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Anthony Della Rosa
Greenhorn

Joined: Mar 19, 2007
Posts: 12
I have added this in the path statement .;C:\Program Files\Java\jdk1.6.0\bin

but it still wont compile
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11320
    
  16

When you say "it still won't compile", does that mean it's finding the javac program, and your code is bad, or that it still can't find the javac program?

note: If you are on windows, you have to close the command window and re-open it for changes to your PATH to take effect.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Should there be an underscore and version number after "jdk1.6.0"? For example...

C:\Program Files\Java\jdk1.6.0_1\bin

Check the actual directory name to verify. (Also note that depending on your operating system, you might need to reboot for this setting to take effect. At the very least, you will need to open a new Command Prompt window.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Anthony Della Rosa
Greenhorn

Joined: Mar 19, 2007
Posts: 12
This is a copy of the code for the HelloWordApp I am trying to compile

/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}

When I compile using textpad it compiles and i can use the program. The file is saved in a folder called Java on C. At the c:\Java prompt I type javac HelloWorldApp.java and the error message returned is

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


Thanks for being patient
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
That means that you don't have the PATH set correctly. Look at Marc's advice and make sure you have the right path.
Anthony Della Rosa
Greenhorn

Joined: Mar 19, 2007
Posts: 12
I have checked it and there is no version number the software installed in this directory

C:\Program Files\Java\jdk1.6.0\bin

this is what the PATH variable is set to

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.6.0\bin

I rebooted as well and I still get the same error I also have the CLASSPATH set to .;C:\Program Files\Java\jdk1.6.0\bin just this and nothing else


[ March 19, 2007: Message edited by: Anthony Della Rosa ]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
What are the contents of C:\Program Files\Java\jdk1.6.0\bin?
[ March 19, 2007: Message edited by: Keith Lynn ]
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2500
    
    8

It's mentioned before, but you should remove 'C:\Program Files\Java\jdk1.6.0\bin' from your CLASSPATH.

This will not solve your problem, but it's incorrect setup.

PATH tells your operating system (windows in your case) where it can find executables (like javac.exe and java.exe).
CLASSPATH tells java where it can find compiled java classes.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11320
    
  16

what happens when you type on the command line:

C:\Program Files\Java\jdk1.6.0\bin\javac.exe


do a dir of that directory, and make sure there really IS a javac.exe in there.
Anthony Della Rosa
Greenhorn

Joined: Mar 19, 2007
Posts: 12
Ok I finally punted. I re-installed the JDK re-booted the computer and compiled and ran several applications with no problems at all. THANK YOU ALL FOR YOUR HELP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JDK at command prompt