Forums Register Login

compiling java program

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
check this
JavaRanch beginner's FAQ

and more specifically this
Sun's first Java steps tutorial
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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...

+Pie Number of slices to send: Send
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 ]
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 730 times.
Similar Threads
Tomcat installation Problem
Run Time error
Set Compiler Compliance Level
Heap Space Error
class path
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:01:57.