File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes classpath problem win2000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "classpath problem win2000" Watch "classpath problem win2000" New topic
Author

classpath problem win2000

davade davade
Greenhorn

Joined: Oct 13, 2004
Posts: 3
javac is unable to recognize classpath in win2000.

I tried setting classpath with no success.

Could this have anything to do with the several hotfixes from Microsoft?
reason is this wayback this OS without the most recent service pack work well on another machine.
Please help what am i doing wrong?
Rob Shields
Greenhorn

Joined: Oct 11, 2004
Posts: 19
Can you post the error message you're getting?

Also try typing echo %CLASSPATH% at the command prompt to see the contents of the classpath system variable.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
You do not set the CLASSPATH environment variable for a standard SDK install.

Some argue (including myself) that setting the CLASSPATH environment variable at any time (i.e. not SDK installation) is a bad idea.


Tony Morris
Java Q&A (FAQ, Trivia)
davade davade
Greenhorn

Joined: Oct 13, 2004
Posts: 3
I never seen such difficulties before.

I tries everything.

I did the same j2sdk1.4.2_06 installation on two machines with similar OS with the same results.
I even tried compile helloworldapp.java thinking it could be my javawsourceCode with similar results.

However helloworldapp.java did compile if I change to the directory path and compile.
But my MainSourceCode.java which call external class will not compile. (See errors below.)

I force classpath setting using Set classpath @ command prompt also set classpath at mycomputer properties, even using Javac -classpath to set classpath. No success.

Here are the errors:
@ c:\ Javac helloworldapp.java
error: cannot read: helloworldapp.java
1 error

@ c:\sourceDir> Javac helloworldapp.java (this compile ok)

But when I use my MainSourceCode.java which requires calling other classes which by the way resides in this same directory the this is what happen:

c:\SourceDir>Javac MainSourceCode.java
MainSourceCode.java:84: unreachable statement
};
1 error

If I were able to compile withing the source directory I would be contented but I am unable to compile source code that requires calling other external classes though they reside in the same directory.

I hope this is detailed enough.

Did anyone see this happening before.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
classpath on NT and Unix like systems (which includes Win2000) does not by default include the current directory.
Add ;. at the end of your classpath.

To be able to compile from anywhere check the javac help, it should tell you that you can include a commandline option -sourcepath <path> and -d <path> to tell the compiler where to read sources and write compiled classfiles.

Type javac -help to get the full list of options.


42
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
You are setting the class path in wrong way. try to clean up the class path and set it again. I am using win 2000 i dont have any problem.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Jeroen points out something very important, but doesn't necessarily state it directly enough:

You seem to be assuming that javac uses CLASSPATH to find *.java files. That's wrong -- it does not. It only uses CLASSPATH to find *.class files. There is a command-line -sourcepath option you can use, or (as I believe is far, far more common) you can compile from the directory where the source is located.

As far as the syntax error in MainSourceCode.java: that has nothing to do with the classpath -- your code needs fixing.

So to say this all again: from your description, it appears that everything is working as its supposed to.
[ October 14, 2004: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
Here is a good link for how to set the classpath on any Windows version:

http://www.cadenhead.org/book/java21/jdkhelp6.shtml
davade davade
Greenhorn

Joined: Oct 13, 2004
Posts: 3
Thanks everyone.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classpath problem win2000