1

Do I have to run set Class and Set ClassPath in Commandline every time for compiling Java programs with these commands

set class ="C:\Program Files\Java\jdk1.8.0_121\bin";  
set classpath="C:\Program Files\Java\jre1.8.0_121\lib\rt.jar"; 
C:\>Javac Test1.java
C:\>Java Test1 

even I added up folder up to bin in environment variable for setting up the environment variable.If I do not run SET CLASS and SET CLASSPATH, I get an error Error: Could not find or load main class Test1

Please answer thanks.

0

2 Answers 2

1

What i would do is :

1) Add jdk path to PATH.
2) Create a folder with all my classes in , the cd to that folder "javac" every class and then "java" the one containing the "main" method.

Sign up to request clarification or add additional context in comments.

Comments

0

You also need the path where your compiled class files are in your classpath!

You only included the tools.jar - but not your class file(s).

When compiling, you should only point to those JVM classes, but when running your application, your classes need to be found too!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.