0

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
2
  • 2
    If you have whitespace in directory name, you should either use a forward slash to escape the name OR put the complete path in quotes. set SOURCE="C:\Documents and Settings\xxx\Desktop" Commented Jan 9, 2012 at 17:56
  • what error message are you getting? Commented Jan 9, 2012 at 17:56

1 Answer 1

2

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

"%JAVA_HOME%\java" -cp "%SOURCE%" Test
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.