• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling java program

 
Smitha Ballikar
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have installed jsd1.4.1.Now I have written a java program.Where do I save it ? from which path I should compile.Do i need to set the classpath or it already gets set when i install the jsdk??

Cheers
Smitha
 
Patrick van Zandbeek
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this
JavaRanch beginner's FAQ

and more specifically this
Sun's first Java steps tutorial
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You never need to set the CLASSPATH variable, ever.

When you compile or run (javac command and java command respectively) the default classpath is the current directory. Do nothing and everything will probably work. Set the CLASSPATH and it will probaby break. Why? A common error is to leave out the current directory, ".", hence, a endless parade of CLASSPATH questions from those starting to use Java.

Now, if you have additional class folders and jars (jars are treated like folders containing classes in a sense) you supply them as follows.

javac -classpath ...
java -classpath ...

Sometimes what you need to run is more than you need to compile, so they aren't always the same. Most intro programs need nothing at all. They use the current directory plus the built-in Java classes.

P.S. The ranch intro contains no information about the default classpath, it should.
 
Patrick van Zandbeek
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SET CLASSPATH=.;C:\fubar\Foo.jar

taken from reading through the javaranch faq under setting the classpath in windows. Not very verbose about default classpath but the dot is definitely there...

 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's good but I was referring to the lack of mention of what the default classpath is. I'm sure people follow that advice and add the dot and probably foo.jar along with it IMO it should state that the default value is the current directory.
[ August 23, 2005: Message edited by: Rick O'Shay ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic