If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

java compile, directory confusion

I think the answer to my question must be an obvious one and shorter than even the question I am a C++ programmer struggling with the first java program for a day or so. There is some code I have to port to java (not long, only a few classes but I have to keep the structure as must as possible). First I try to have two files compiled and running but could not achieve that for a day.

I actually created those with NetBeans and can compile/run. It needs to be integrated to the usual make process (now on Windows, later on linux). That should be no problem given that compilation of those will be successful (maybe .jar later, not that far yet).

C:\MyProject\proj1.java>java -cp C:\MyProject\proj1.java\_classes C:\MyProject\p
roj1.java\_classes\Api\Test\Test
Caused by: java.lang.ClassNotFoundException: C:\MyProject\proj1.java\_classes\Ap
i\Test\Test
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: C:\MyProject\proj1.java\_classes\Api\Test\Test.
Program will exit.

Re: java compile, directory confusion

Thanks for the reply, at least there is some change:

Code:

C:\MyProject\proj1.java>java -cp C:\MyProject\proj1.java\_classes Api\Test\Test
Exception in thread "main" java.lang.NoClassDefFoundError: Api\Test\Test (wrong
name: Api/Test/Test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: Api\Test\Test. Program will exit.

I will most probably go for lower case as you suggested, later when this one works.