Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation vs run

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dattatraya Baravkar
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic