• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problem with JDK at command prompt

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic