|
|
Re: Question about package in Eclipse [message #654740 is a reply to message #654734] |
Wed, 16 February 2011 21:50 |
|
On 16-Feb-11 14:09, Teal_Candle wrote:
> [snip]
> Now when I trying running this in cmd in Windows, it gives me the
> following error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> Folder1/Folder2/Folder3/helloWorld
> Caused by: java.lang.ClassNotFoundException:
> Folder1.Folder2.Folder3.helloWorld
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> Could not find the main class: Folder1.Folder2.Folder3.helloWorld.
> Program will exit.
You've not created a "runnable" JAR, right? You can't generate a common
("library") JAR and run it. Use File -> Export -> Java -> Runnable JAR
File... see if you can't figure it out from there. (Or, did you do this
and I'm just not reading your problem?)
> However if I take the package Folder1.Folder2.Folder3; out of the
> beginning of my file, Eclipse throws an error saying its expecting a
> package, however if I save the file and compile outside of eclipse it
> then runs fine.
> [snip]
As long as your Java file is down inside a package, the package
statement at the top of the file must match the package it's in.
Russ
|
|
|
Powered by
FUDForum. Page generated in 0.08524 seconds