File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Trying to Understand Java and JRE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trying to Understand Java and JRE" Watch "Trying to Understand Java and JRE" New topic

Trying to Understand Java and JRE

Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

[Hello all, I've just compiled my first java application and now I'm ready to test it. However I'm just a little confused as how to go about this.
From what I've gathered thus far, I'm supposed to "execute" the source code which actually uses the class files generated by the compiler.
My environment is Windows 2008 32bit server, I have IBM's java SDK 1.6 installed.
Should the JVM be running as a "service" in Windows ? (I looked in the list of system services currently running, but i did not "see" a JVM in the list.
Of course I'm assumming the JVM would be called JVM ...
Any suggestions would be most welcome.


fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

no, it is not a service, it is a program you call from the command line.


then, cd to the directory where your .class file is.

then type "java <yourclassname>"

note that you do NOT type the ".class". So, if I had a file named "", after compiling I'd have a "MyClass.class" file. I'd run it with "java MyClass".

and also, even though Windows is not case sensitive, Java is, so "java myclass" would not work.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

Thanks very much Fred
Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

Hi All ... I'm still getting errors to wit:
C:\>set CLASSPATH=C:\APPC_LU62\java

C:\>java LU62XnsCvr
Exception in thread "main" java.lang.NoClassDefFoundError: LU62XnsCvr (wrong name: APPC_LU62/java/LU62XnsCvr)
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(
at Source)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(

I don't understand what is meant by "wrong name" when there is indeed a class file named LU62XnsCvr.class

C:\>cd APPC_LU62\java

C:\APPC_LU62\java>dir /p
Volume in drive C has no label.
Volume Serial Number is B62B-74FF

Directory of C:\APPC_LU62\java

05/04/2011 05:34 AM <DIR> .
05/04/2011 05:34 AM <DIR> ..
05/03/2011 06:53 PM 1,492 LU62XnsCvr$cntrl_status.class
05/03/2011 06:53 PM 1,253 LU62XnsCvr$recv_status.class
05/03/2011 06:53 PM 1,689 LU62XnsCvr$system_code.class
05/03/2011 06:53 PM 15,230 LU62XnsCvr.class

Below is the source code that I compiled ...

Now it's my understanding that when one uses the "package" option there has to be a corresponding path that matches the package "label"
e.g. package and I have a directory structure C:\APPC_LU62\java where the generated class files are "stored".

There's no apparent mispelling of the class name as far as I can 'see'
public class LU62XnsCvr extends Object

and in the directory itsself
05/03/2011 06:53 PM 15,230 LU62XnsCvr.class

All suggestions, ideas, and comments are most appreciated.

Best Regards

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Your classpath needs to be set to a directory which is the root of the package; in your case, the classpath should be "C:\". That way, the Java runtime uses the classpath to look up the full name of your class, which is, and which it expects to find in a directory structure that includes the directories as you have them.

Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

okay Ralph ...thanks very much ... I'll try that

Best Regards
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46353
Is it possible to remove your classpath altogether, and then navigate to the root of your directory structure? If there is no classpath at all, the "java" tool will default to using the current directory as its classpath.
I agree. Here's the link:
subject: Trying to Understand Java and JRE
It's not a secret anymore!