user595234
user595234

Reputation: 6259

java compile classpath

I want to code a script to compile and run a java file in the Windows env, but failed. It is failed in the java classpath.

This Test.java is not inside any package.

Please help. Thanks.

set SOURCE=C:\Documents and Settings\xxx\Desktop
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_25\bin
"%JAVA_HOME%\javac"  "%SOURCE%\Test.java"
pause

"%JAVA_HOME%\java" -cp "%SOURCE%" Test.class
pause

Upvotes: 0

Views: 410

Answers (1)

dogbane
dogbane

Reputation: 274838

Try removing the .class extension from the name of the class you pass to the java command:

"%JAVA_HOME%\java" -cp "%SOURCE%" Test

Upvotes: 2

Related Questions