1.

Solve : javac Command Prompt Issue?

Answer»

Hello all,

I am trying to learn Java (just for fun at the moment) and am working on reading "Fundamentals of Java: AP COMPUTER Science Essentials for the A Exam" 3rd Edition (2006) by Ken Lambert and Martin Osborne. I am in the second chapter ("First Java Programs") and am trying to run the "HelloWorld" program. My problem is in compiling the program. I am using a computer running Windows XP Home SP3 and am using the Command Prompt to attempt to run the program rather than what the book calls an Integrated DEVELOPMENT Environment.
In order to run a program, the book explains you need to install a Java development environment, so I went to Oracle's website and downloaded (and installed) the "jdk-6u23-windows-i586.exe" file. After installing, I typed in the Hello World code given in the book in Notepad and saved it as a ".java" file. I opened the Command Prompt window, navigated to the directory which contained the HelloWorld.java file and typed in "javac HelloWorld.java". Instead of compiling into byte code however, I got a message in the Command Prompt window saying " 'javac' is not recognized as an internal or external command, operable program or batch file."

If anyone could help identify why I can't get the HelloWorld file to compile into byte code I would be very grateful.

Thanks

Here's the code I used in my HelloWorld.java file (I modified slightly for appearance):


// Example 2.11: Our First Program

public class HelloWorld
{

public static void main(String [] args)
{
SYSTEM.out.println(" d ");
System.out.println(" o l ");
System.out.println(" l r ");
System.out.println(" l o ");
System.out.println(" e w ");
System.out.println(" H ");
System.out.println(" ***************** ");
System.out.println(" * * * ");
System.out.println(" * * * ");
System.out.println(" * ***** ");
System.out.println(" * * ");
System.out.println(" * * ");
System.out.println(" * * ");
System.out.println(" ************* ");
}
}The folder that contains javac.exe should be in your PATH system variable if you just want to type javac xxx.java. If it is not on your PATH and it seems like yours is not, you have to type the full path to javac.exe. Do you know which folder it is installed into? Did you follow the install instructions carefully? have you restarted the computer since installing Java?
Quote from: Salmon Trout on December 23, 2010, 10:19:51 AM

The folder that contains javac.exe should be in your PATH system variable if you just want to type javac xxx.java. If it is not on your PATH and it seems like yours is not, you have to type the full path to javac.exe. Do you know which folder it is installed into? Did you follow the install instructions carefully? have you restarted the computer since installing Java?

Hey Salmon, thanks for your response.

I found the javac.exe file in "C:\Program Files\Java\jdk1.6.0_23\bin" (I had the JDK install in its suggested location). I did find the "java.exe", "javaw.exe", and "javaws.exe" in "C:\WINDOWS\system32" folder (that would be the Path folder right?; I don't know hardly anything about Paths) in addition to being in "C:\Program Files\Java\jdk1.6.0_23\bin" folder.

When I did the installation (I installed it yesterday), I followed the instructions provided by the installer dialogue box, but I MIGHT have over looked special instructions if they were on Oracle's website.
As far as a restart, I did not restart the computer right after the installation completed but instead tried to get the Hello World program to run (obviously unsuccessfully). Since yesterday and today however, the computer has been restarted.

Would you recommend uninstalling the JDK and reinstalling it or is there a simpler fix to this issue?Did you uninstall any PREVIOUS versions of Java (JRE for example) before you installed the JDK?




Discussion

No Comment Found