If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
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.

New to Java, Confused about jar files and packages.

I have a file by name MSWord.java:

Class name MSWord

package org.jinterop.dcom.test;

This file is located at C:\Documents and Settings\xxxx\Desktop\Java Files New

Environment Variable: Value:

CLASSPATH .;C:\Program Files\QuickTime\QTSystem\QTJava.zip;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\j-interop.jar;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\jcifs-1.2.19.jar;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\j-interopdeps.jar;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\progIdVsClsidDB.properties;C:\glassfishv3\jdk\bin;C:\glassfishv3\jdk\lib;

Exception in thread "main" java.lang.NoClassDefFoundError: org/jinterop/dcom/tes
t/CSFT
Caused by: java.lang.ClassNotFoundException: org.jinterop.dcom.test.CSFT
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.jinterop.dcom.test.ControlSoft. Program will
exit.

I dont understand where is the realtion for the package and the classpath etc. Why am i getting the error and what should i do to execute my new file.

Re: New to Java, Confused about jar files and packages.

The Java command doesn't run the .java file it runs the .class file which must be in a directory structure based on the package name. Therefore, somewhere on the classpath there is a a directory structure of org.jinterop.dcom.test which contains the class file MSWord.class.

Re: New to Java, Confused about jar files and packages.

Thanks for the quick response, you were right the directory structure

org/jinterop/dcom/test/MSWord.class is present in j-Interop.jar which is present in the classpath.

Now how do i get my new class here, do i have to generate a new jar file. j-Interop.jar is located at C:\Documents and Settings\xxxx\Desktop\j-Interop. But MSWord.java is not present anywhere in the directory of j-interop.jar, an execute.bat file of MSWord.java is present in the directory of j-interop.

Re: New to Java, Confused about jar files and packages.

You shouldn't try to put your class file in jar file that isn't under your control. For a start it may be signed in which case adding your file will break the jar.

You can solve your problem by creating the directory structure on your hard disk and putting the class file in 'test' directory. The root of this directory structure, the 'org' directory must be in a directory that is on the classpath.

Re: New to Java, Confused about jar files and packages.

Originally Posted by keang

The Java command doesn't run the .java file it runs the .class file which must be in a directory structure based on the package name. Therefore, somewhere on the classpath there is a a directory structure of org.jinterop.dcom.test which contains the class file MSWord.class.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.