javac not a valid command

I reformatted my computer several months ago, and just recently reinstalled the JDK for my programming classes.

I followed the directions I found on installation, and added C:\Program Files\Java\jdk1.5.0_06\bin to my PATH variable.

I use the TextPad program to write and compile my Java programs, and have been for almost three years now.

An interesting problem occured when I attempted to compile a program I had already succeded in compiling AND running on a university lab computer. I was using the same exact code, but it was coming back with tons of errors. It seemed to not be finding the other classes it was pulling from.

After the failed compiling with TextPad, I decided to go to the command line and attempt to compile the files that way. I got the following error:

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

Any help would be GREATLY appreciated!

[954 byte] By [agdistisa] at [2007-10-2 15:16:13]
# 1

Set the path as a System Variable toward the bin. make sure the bin contains javac.exe and you didn't delete any java-included files.

If you're using windows xp, right-click My Computer+Advanced Tab+Click Enviroment Variables+Lower Box (System Variables not User Variables)+Select PATH+Click Edit Path+ scroll to end and add C:\Program Files\Java\jdk1.5..0_06\bin+click ok 3 times+restart computer

V.C.

Vincent_Chunga at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...
# 2
I did this, even wiped java clean and tryed installing it again.I'm still having the same problems.
agdistisa at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...
# 3

As Vincent_Chung said, verify that the file javac.exe exists and is correctly located. Set the path as he instructed.

If you still get the "javac cannot be located. . ." error, open a cmd window and type "echo %path%". Verify that the path is correctly set. Make sure that there are no unwanted spaces.

If the path appears correct, but the problem still exists, copy and paste the echo results here.

ChuckBinga at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...
# 4
Javac.exe is present in the directory C:\Program Files\Java\jdk1.5.0_06\bin.I am still getting the same error.echo %path%C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\; C:\Program Files\Java\jdk1.5.0_06\bin
agdistisa at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...
# 5
If you still get the "javac cannot be located. . ." error, open a cmd window and type "echo %path%". Verify that the path is correctly set. Make sure that there are no unwanted spacesYou have an illegal space.
ChuckBinga at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...
# 6

Ah! I see! I've got that working now, thanks! :)

I'm still having a problem compiling however. The code I'm compiling is as follows:

public class TestDoAdd {

public static void main(String args[]) {

DoAdd da = new DoAdd();

ColorChart color = new ColorChart();

AgeGame age = new AgeGame();

//Test add()

System.out.println("The result of the addition 2 + 3 = "

+ da.add2(2, 3) );

//Test add()

System.out.println("The result of the addition 2 + 3 + 4 = "

+ da.add3(2, 3, 4) );

//Test add

System.out.println("The result of the addition 2 + 3.25 = "

+ da.addNums(2, 3.25));

//Test colorChart

System.out.print( "\n" + "Please enter a character to represent your color: ");

System.out.println( color.selectColor( MyInput.readChar() ) );

//Test AgeGame

System.out.print( "\n" + "Please enter your age: ");

System.out.println( age.mult7(MyInput.readInt() ) );

}

}

When I compile this through TextPad I get error messages like the following for each reference to another class. All classes have been sucessfully compiled and are in the same folder as TestDoAdd.

[quote]C:\Documents and Settings\Rakuen\Desktop\PE1\TestDoAdd.java:16: cannot find symbol

symbol : class DoAdd

location: class TestDoAdd

DoAdd da = new DoAdd();

^[/quote]

Now, when I compile this same code through the command window, it compiles with no errors. But gives me the following error when I attempt to run the program.

Exception in thread "main" java.lang.NoClassDefFoundError: TestDoAdd

All classes called by TestDoAdd as well as TestDoAdd have been sucessfully compiled and run on a computer in my university computer lab.

agdistisa at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...
# 7

I cannot help you with the setup of Textpad - it's not correct, refer to its documentation.

At the command window - make sure that all of the necessary classes exist and are in one directory. Change the command prompt to that directory, and issue this command:

java -classpath . <name of your class>

IMPORTANT: include the period and surrounding spaces

If that works, learn about finding classes and using the classpath here:

http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html#general

ChuckBinga at 2007-7-13 14:19:13 > top of Java-index,Developer Tools,Java Compiler...