aspose file tools*
The moose likes Beginning Java and the fly likes compilation vs run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation vs run" Watch "compilation vs run" New topic
Author

compilation vs run

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hi all,

to run a java file,we need to set class path right?.

but java file is compiling without class path!..

i am confusing....

please any one can explain me...

thanks & regards,
seetharaman
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
You always need to set the classpath, for compilation and for running. It's just that if you're compiling a single Java source file, then it doesn't depend on any other classes, and so there is nothing to put in the classpath.

But if you have two source files -let's say A and B, and A uses a B object- then you can't compile A without setting the classpath to include B.


Ping & DNS - my free Android networking tools app
Dattatraya Baravkar
Greenhorn

Joined: Jan 24, 2008
Posts: 10
Please see the location of the program you have saved, if the program is inside the bin folder of the jdk then there is no need to setpath for the jdk....
please take a look at it.........
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
The PATH has nothing to do with the CLASSPATH (which the question is about). Plus, keeping user classes or programs in the JRE's bin directory in very bad practice.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

thanks ulf dittmer..

one more question..

i have my javafile in d:/program location

now i want to compile as well as run the file..

now,how to set the class path...

i try to give java installation folder(upto bin directory) into classpath(environment variable)..but it is not working..

please clarify my question



thanks & regards,
seetharaman
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
Again, no classes should be put into the bin directory, and so it should not be part of the CLASSPATH.

I never use the CLASSPATH environment variable, but instead use the -classpath command line switch, like

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation vs run