Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » running package
running package [message #212863] Wed, 30 May 2007 14:10 Go to next message
dendeezen is currently offline dendeezenFriend
Messages: 6
Registered: July 2009
Junior Member
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 #212881 is a reply to message #212863] Wed, 30 May 2007 15:35 Go to previous messageGo to next message
Eclipse UserFriend
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 #212901 is a reply to message #212863] Wed, 30 May 2007 15:55 Go to previous messageGo to next message
Mark Dexter is currently offline Mark DexterFriend
Messages: 324
Registered: July 2009
Senior Member
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:

Hi. So you have 6 files with the .class names -- correct? How are you
wanting to deploy this? Normally, you would put them all in a .JAR file so
you don't have to deploy 6 separate files. If so, you just use the Eclipse
export (File / Export / Java Jar file). Make sure you specify which class
contains the main method. Once you do this, the .JAR file can be run with
the command: java -jar myapp.jar

In Windows, you can normally just double-click on the .JAR file and it
runs as javaw -jar myapp.jar.

If you want to run the application as separate class files, I think you
need to have the directory that contains the .class files in your Java
CLASSPATH directory (or use the -cp command line option with java).

I think the .JAR file is the best way to go. Hope this helps. Mark Dexter
Re: running package [message #212996 is a reply to message #212863] Thu, 31 May 2007 09:06 Go to previous messageGo to next message
dendeezen is currently offline dendeezenFriend
Messages: 6
Registered: July 2009
Junior Member
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,
Re: running package [message #213028 is a reply to message #212996] Thu, 31 May 2007 12:26 Go to previous message
Eclipse UserFriend
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,
>
>
Previous Topic:example source where?
Next Topic:Files keep reloading from disk
Goto Forum:
  


Current Time: Fri Apr 26 13:31:14 GMT 2024

Powered by FUDForum. Page generated in 0.09462 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top