I'm trying to run a simple unit test to my project at https://github.com/cdwijayarathna/oj4j.
I added both junit-4.12.jar and ant-junit4.jar to the lib folder.
But when I ran "rake run_tests", I'm getting following error at the report location I have given.
java.lang.NoClassDefFoundError: junit/framework/JUnit4TestAdapterCache
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
What's the reason for that? how can I solve this?
I had the same exception running junit through ant on Debian. By including the junit4.jar in the $CLASSPATH environment variable I was able to get it running. Which means the jvm was not picking up on the junit4.jar. The /usr/share/java/junit4.jar path is specific to Debian's junit package, so you will need to replace as appropriate.
$ export CLASSPATH=/usr/share/java/junit4.jar
$ ant test
I use specific jars to run tests on a project, here is the command line which solve this issue:
$ CLASSPATH=lib/hamcrest-core-1.3.jar:lib/junit-4.12.jar ant my-junit-target
I've wrote a small shell to encapsulate this command.
Set ANT_HOME your $CLASSPATH environment variables.
Related
My application supported on:
Jdk1.7.0_76,
JavaFx2.2.76_b13,
Netbeans IDE,
Ant for building and creating installer.
Supported on Windows and Mac.
It's running successfully till High-Sierra
When I tried to run .app file on Mojave it is giving
Unable to load Info.plist exceptions (eGPUOverrides)
And when I tried to run jar file it gives following error
Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 13 more
let's say in a package using Java we are using 4 files.
First one say StudentModel.java ,second one say studentView.java,the third studentController.java and fourth studentMain.java.
Then I compiled these files in these order in one line studentModel.java , studentView.java , sudentController.java and studentMain.java.
But I received the following runtime error while running this command :
java studentMain
in spite of having the respective .class files in the folder :
Exception in thread "main" java.lang.NoClassDefFoundError: studentMain (wrong name: student/studentMain)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
I am including the picture of terminal while executing the
java studentMain
command.
RunTime Error Image1
RunTime Error while setting the classpath
I keep getting this error when I attempt to run compiled Groovy code in IntelliJ IDEA 13:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java -Didea.launcher.port=7539 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 13.app/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/javafx-doclet.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/htmlconverter.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/Insanity/Documents/Programming/Programming Languages/Groovy/Asteroids!/out/production/Asteroids!:/Users/Insanity/Desktop/:usr:local/opt/groovy/libexec/lib/ant-1.9.2.jar:local/opt/groovy/libexec/lib/ant-antlr-1.9.2.jar:local/opt/groovy/libexec/lib/ant-junit-1.9.2.jar:local/opt/groovy/libexec/lib/ant-launcher-1.9.2.jar:local/opt/groovy/libexec/lib/antlr-2.7.7.jar:local/opt/groovy/libexec/lib/asm-4.1.jar:local/opt/groovy/libexec/lib/asm-analysis-4.1.jar:local/opt/groovy/libexec/lib/asm-commons-4.1.jar:local/opt/groovy/libexec/lib/asm-tree-4.1.jar:local/opt/groovy/libexec/lib/asm-util-4.1.jar:local/opt/groovy/libexec/lib/bsf-2.4.0.jar:local/opt/groovy/libexec/lib/commons-cli-1.2.jar:local/opt/groovy/libexec/lib/commons-logging-1.1.1.jar:local/opt/groovy/libexec/lib/gpars-1.1.0.jar:local/opt/groovy/libexec/lib/groovy-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-ant-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-bsf-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-console-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-docgenerator-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-groovydoc-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-groovysh-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-jmx-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-json-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-jsr223-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-servlet-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-sql-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-swing-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-templates-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-test-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-testng-2.2.2.jar:local/opt/groovy/libexec/lib/groovy-xml-2.2.2.jar:local/opt/groovy/libexec/lib/hamcrest-core-1.3.jar:local/opt/groovy/libexec/lib/ivy-2.3.0.jar:local/opt/groovy/libexec/lib/jansi-1.10.jar:local/opt/groovy/libexec/lib/jcommander-1.27.jar:local/opt/groovy/libexec/lib/jline-2.10.jar:local/opt/groovy/libexec/lib/jsp-api-2.0.jar:local/opt/groovy/libexec/lib/jsr166y-1.7.0.jar:local/opt/groovy/libexec/lib/junit-4.11.jar:local/opt/groovy/libexec/lib/multiverse-core-0.7.0.jar:local/opt/groovy/libexec/lib/qdox-1.12.1.jar:local/opt/groovy/libexec/lib/servlet-api-2.4.jar:local/opt/groovy/libexec/lib/testng-6.8.5.jar:local/opt/groovy/libexec/lib/xmlpull-1.1.3.1.jar:local/opt/groovy/libexec/lib/xstream-1.4.4.jar:/Users/Insanity/Documents/Programming/Programming Languages/Java/Libraries/Java Game Libraries/slick/lib/slick.jar:/Users/Insanity/Documents/Programming/Programming Languages/Java/Libraries/Java Game Libraries/lwjgl-2.9.1/jar/lwjgl.jar:/Applications/IntelliJ IDEA 13.app/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain com.insanity.asteroids.Init
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 15 more
Process finished with exit code 1
By the looks of it the Groovy libs are not being found or something.
The problem is that I was using a symlink that pointed to /usr/local. The error was fixed by changing the classpath to use the direct path of /usr/local instead of a symlink.
tl;dr: Don't set your classpath in IntelliJ using a symlink.
I wrote a project in NetBeans IDE in my computer, and I ran it. That was OK. I transferred it into my Friend's computer. I ran it with NetBeans, but I got these errors:
java.lang.UnsupportedClassVersionError: friendspro/Server/RunServer : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: friendspro.Server.RunServer. Program will exit.
Exception in thread "main" Java Result: 1
///
When I ran my project in my computer in CMD, I got the same error:
C:\Users\Blue\Desktop\FriendsPro\src\friendspro\Server>java RunServer -ORBIniti
alRef NamingServic=corbaloc::localhost:1049/NameService
Exception in thread "main" java.lang.NoClassDefFoundError: RunServer (wrong name
: friendspro/Server/RunServer)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)
It's not the same error. Your friend has an older Java version. Here's how to target older Java versions in NetBeans: Target JDK for Java Applications.
You are running your program incorrectly. You need to do
java friendspro.Server.RunServer -ORBIniti ...
in your main directory (probably bin or src).
On your computer, open CMD, cd to your source directory and then, as Banthar specified,
java friendpro.Server.RunServer ...
I'm a student, and I'm trying to write an RMI application.
I have 3 separate projects:
One is Server Side
One is Common (include Interface and Entities to reflect with Database Structure)
One is Client
and I write it on Netbeans IDE.
When I start server I receive a printstack error like this:
Exception in thread "main" java.lang.NoClassDefFoundError: rmi/cosmetic/Interfaces/ICategories
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at Server.ServerSide.main(ServerSide.java:22)
Caused by: java.lang.ClassNotFoundException: rmi.cosmetic.Interfaces.ICategories
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 13 more
Java Result: 1
rmi/cosmetic/Interfaces/ICategories
is the path of file Interface Categories, it has been contained in Common Project for both of 2 sides client and server
I have no idea about this issue. I try to set classpath on my windows but it didn't work.
Can someone please help me?
Some images, to make it clear
http://upanh.7nghiep.com/vgo-images/vgo.vn-qIntT.jpg
http://upanh.7nghiep.com/vgo-images/vgo.vn-jaJw0.jpg
upanh.7nghiep.com/vgo-images/vgo.vn-RvxIo.jpg
upanh.7nghiep.com/vgo-images/vgo.vn-DvuMt.jpg
upanh.7nghiep.com/vgo-images/vgo.vn-OI9rL.jpg
Caused by: java.lang.ClassNotFoundException:
rmi.cosmetic.Interfaces.ICategories
There's your problem right there. Your Registry or your client can't find that class. It needs to be on their CLASSPATH.