Results 1 to 2 of 2
- 01-22-2010, 08:31 PM #1Member
- Join Date
- Jan 2010
- Rep Power
java run correctly in the upper directory
I compile By javac some java sources with this sintax:
javac -cp .;c:\com MenuExample.java
this source code are in the directory C:\com\a1\
the compiler makes 2 classes: MenuExample.class and MenuExample$1.class
now if I run it, in the same directory, with
java -cp .;c:\com MenuExample
there is a error messagge:
java.lang.NoClassDefFoundError: MenuExample (wrong name)
if I go to the upper directory (C:\com) and I entry
java a1.MenuExample the program run normally.
I not understand the reason of this behavior.
Thanks in advance
- 01-29-2010, 07:52 PM #2
this has to do with the file MenuExample.java being in the java 'package' com.ai.MenuExample.
the javac compiler is more forgiving about where it is invoked on the file system path, as it is reading a .java file and generating a .class file. where as the java VM to run this .class file needs to work from the top level of the class path, which is the folder that contains (in this case) the "com" folder. it is also confusing at first because a java package corresponds to a folder on the file system in the sources.
- By Valeriano in forum New To JavaReplies: 16Last Post: 03-01-2010, 01:39 PM
- By elektronika in forum New To JavaReplies: 7Last Post: 12-10-2009, 12:23 PM
- By JavaInLove in forum Java 2DReplies: 3Last Post: 03-17-2009, 09:38 PM
- By abcd in forum Java AppletsReplies: 7Last Post: 01-28-2008, 08:53 AM
- By osval in forum New To JavaReplies: 1Last Post: 08-06-2007, 09:55 PM