zhbcool
March 17th, 2008, 09:55 PM
I am new to java and was working on a program in which i defined some math functions and i have to test whether the functions i wrote are correct by testing the functions and checking if the answer the function gives is the same as the correct answer. I have written the code but it gives me the following error:
java.lang.NoClassDefFoundError: java/assingment6/Driver
Exception in thread "main"
I am using Java Eclipse I have attached a zip file that contains the program. Thanks in advance.
zhbcool
March 17th, 2008, 10:30 PM
Actually now I have a different error it is the following:
java.lang.SecurityException: Prohibited package name: java.assingment6
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
petes1234
March 17th, 2008, 10:53 PM
I don't know why the compiler is complaining about your package name. Is it the same as the package name in the eclipse package explorer on the left? If not, you'll have to adjust it.
Two other problems. First of all, you should post your code rather than a zip of the code. We generally don't want to see all of it, but rather you should condense your code into the smallest bit that still compiles, has no extra code that's not relevant to your problem, but still demonstrates your problem, in other words, an SSCCE (Short, Self Contained, Correct (Compilable), Example). For more info on SSCCEs please look here:
http://homepage1.nifty.com/algafield/sscce.html
Again, if the code is compilable and runnable many of us to be able to better understand it.
Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, either use the "code" button at the top of the forum Message editor or place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
[code]
// your code block goes here.
// note the differences between the tag at the top vs the bottom.
[/code]
Finally, your Drivers.java class appears to be running code outside of a defined method. You may want to put most of that code inside of a main method. Good luck.
dlorde
March 18th, 2008, 05:49 AM
Actually now I have a different error it is the following:
java.lang.SecurityException: Prohibited package name: java.assingment6
You can't use the 'java' package for your own classes, it's Sun's top-level package. I don't think they'd approve of you adding your stuff to it ;)
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live...
M. Golding