|
Re: running package [message #212881 is a reply to message #212863] |
Wed, 30 May 2007 15:35 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Don't you need to specify the fully qualified class name, i.e.,
Trimix.Trimixlogin? Your package names should be lower case and
generally should start with com, org, edu, or some other domain suffix...
dendeezen wrote:
> Hi,
> I am a Java (and also an eclipse) newbie. I created a package (Trimix)
> composed of 6 classes and everything works fine in Eclypse, but when I
> try to run this with a command (java Trimixlogin) I get:
>
> Exception in thread "main" java.lang.NoClassDefFoundError: Trimixlogin
> (wrong name: Trimix/Trimixlogin)
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoade r.java:124)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276 )
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>
> On top of every class file I have: package Trimix;
>
> Slowly please.
>
> Thanks,
>
|
|
|
|
|
Re: running package [message #213028 is a reply to message #212996] |
Thu, 31 May 2007 12:26 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Dendeezen,
Each class with a main method can be run directly and when doing so
invokes the main method of that class with the additional arguments you
have on the command line. So he just means specify "a" class with a
main method, and he assumed there was only one so he use the word
"the". All Java compilers will create such additional classes for
things like anonymous inner classes, like when you do "new Something() {
.....}".
dendeezen wrote:
> Hi,
> thanks for helping.
> I had indeed to get out of the dir created by Eclypse and do 'java
> Trimix.Trimixlogin' and not 'java Trimixlogin ' in the dir.
>
> This was only for testing.
>
> Mark wrote:
>
> Make sure you specify which class contains the main method.
> How do I do this? I have 2 classes with a main method?
>
> Someting else:
> I notified that Eclipse makes several classes from 1 java file;
> myfile.java gives myfile.class, myfile$1.class and myfile$2.class.
>
> Why?
>
> Thanks,
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.09462 seconds