This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Problem with JDK at command prompt  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
lowercase baba
Bartender
Posts: 12627
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to set you PATH to include the jdk/bin directory, not the CLASSPATH.
 
Anthony Della Rosa
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12627
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Anthony Della Rosa
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the contents of C:\Program Files\Java\jdk1.6.0\bin?
[ March 19, 2007: Message edited by: Keith Lynn ]
 
Bartender
Posts: 2633
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12627
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!