Results 1 to 4 of 4
Thread: Running object-oriented in Unix
- 03-28-2012, 08:29 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 11
- Rep Power
- 0
Running object-oriented in Unix
I have written 2 classes, one is an object, and the other manipulates the object and has the main method. It runs perfectly in my IDE (Eclipse), but since this will be running on a server, it needs to also compile and run in Unix/Linux.
Company.java is the object, and Magic.java is the rest.
My commands are as follows:
javac Company.java Magic.java
java Company Magic
Here is where I get an error.
Exception in thread "main" java.lang.NoClassDefFoundError: Company (wrong name: Counts/Company)
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(Secure ClassLoader.java:141)
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.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
Can someone tell me what I'm doing wrong? Thanks.
- 03-28-2012, 08:46 PM #2
Re: Running object-oriented in Unix
NoClassDefFoundError: Company (wrong name: Counts/Company)
Is there a package statement in the Company.java file? That will change the class name to include the package name meaning that you have to tell the java command the full classname(includes the package and the classpath for the java command must point to the folder that contains the package folder.
Easiest way to get this to work is remove the package statement.If you don't understand my response, don't ignore it, ask a question.
- 03-28-2012, 09:20 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 11
- Rep Power
- 0
Re: Running object-oriented in Unix
Thanks! That fixed my problem.
- 03-28-2012, 09:22 PM #4
Similar Threads
-
help for Object Oriented Programming RMI
By clapton in forum New To JavaReplies: 0Last Post: 03-20-2012, 07:42 PM -
New to object-oriented
By fluteattack in forum New To JavaReplies: 6Last Post: 03-28-2011, 02:43 PM -
Help in object oriented programming .
By renu in forum New To JavaReplies: 18Last Post: 10-26-2010, 08:57 PM -
Object Oriented
By GraemeH in forum New To JavaReplies: 3Last Post: 03-29-2009, 08:50 PM -
Object- Oriented guide?
By sciguy77 in forum New To JavaReplies: 4Last Post: 01-18-2009, 04:33 AM
Bookmarks