1.

Solve : Java Classpath problem...?

Answer»

Hi everyone,

I have a little problem, let me explain the situation.
I have made a .java file in Eclipse (Im working on WINDOWS 7 ULTIMATE atm). I compiled it, ran it, it worked.
Now I moved the class file to another directory (I:\System\java).
In I:\System\java\JavaWin i have a portable version of java 1.6.0_30-b12 (launcher made by PortableApps.com)
This works and does everything I want to, I can check the version number etc...
I made a bat file containing the following Code: [Select]JavaWin\bin\java OS > log.txtThis works. This is because the bat file is in the same directory as the .class file.
But when I open cmd leave the directory at C:\Users\Myname and then excecute this command it doesn't work (I left out the log.txt part for now).
Code: [Select]I:\System\java\JavaWin\bin\java I:\System\java\OsOnce again, because the current directory isn't the same as the directory of my .class file this won't work. (it throws a NoClassDefFoundError)
Then I tried adding the classpath:
Code: [Select]I:\System\java\JavaWin\bin\java -cp I:\System\java\ I:\System\java\OsStill to no avail.
Yes my Os.java file contains a public STATIC void main etc etc, so that's not the problem.
I tried everything, adding -cp, -classpath, all the options I found by googlin, nothing works.
Java is installed on my system, but I want to use the portable version, if possible...

Can somebody help me with this silly issue?
Thanks in advance!
Um, why is nobody answering?
Is this so hard to fix/so UNUSUAL

EDIT: I fixed it, thanks to lina19 =)
Code: [Select]I:\System\java\JavaWin\bin\java -cp I:\System\java\ OsHence, the Class parameter, is the classname, not the path to the .class file



Discussion

No Comment Found