This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes setting the class path on win NT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting the class path on win NT" Watch "setting the class path on win NT" New topic
Author

setting the class path on win NT

Mike Pirrone
Ranch Hand

Joined: Oct 30, 2001
Posts: 33
whats up guys? I've been in this java class in college for about 7 weeks now and our lab is still not compiling or running any java code. I tried setting the classpath as I did at home (win xp) and i still cannot get anything to compile. so i was wanting to know how to get this thing going on NT. any links? thanks
-mike-
Mike Pirrone
Ranch Hand

Joined: Oct 30, 2001
Posts: 33
oops.. its win 2000
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
First, are the JDK binaries in your PATH? Ie, can you type
java -version

at a command prompt and get a response or does it report it's an unknown command?
Second, what exactly are you trying to compile? One file? One package? Or a complex source tree with many classes, packages, and libraries?
If you're just doing entry-level stuff, you can get by with just providing the classpath as a parameter to the javac and java commands.
For real-world applications, I don't use the CLASSPATH environment variable because it's too limiting. Instead, I will create batch files that set the classpath depending on what I'm trying to do.
If you have a single java source file like HiDude.java...

public class HiDude{
public static void main(String[] args)
{
System.out.println("Hi dude");
}
}
to compile this:
1) CD in the command console to the directory where HiDude.java is.
2) type javac -classpath "./" HiDude.java
That will compile it.
To run it, type
java -classpath "./" HiDude.
Good luck!


Rob
SCJP 1.4
Tetsuo Suzuki
Greenhorn

Joined: Feb 21, 2002
Posts: 22
Right click on My Computer --> Click on Advanced --> Set Environment Variables. Funny enough, if you use a batch file, it doesn't keep the EVs once you close the console window. Also, you may have to close and re-open the console window in order to have your Environment Variables applied. The easiest way, d00d, to make it work is to download TEXTPAD and just use it to compile. I've never gotten my CLASSPATH issues all straightened out, especially since I use multiple pieces of software (JBUILDER/TOMCAT etc.. ).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: setting the class path on win NT
 
Similar Threads
Retrieving Win NT Users using Java / ADSI Programming in Java
generate javadoc dynamicly
How to get user login info
Retrieving WinNT Users, UserPassword, UserGroups in Java
set classpath=