How to run a project that written in NetBeans on another computer? - java

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 ...

Related

Newly-installed Ant doesn't run on Mac OS 10.12.5

I just installed apache-ant using MacPorts:
sudo port install apache-ant
When I type ant -version, I get the following:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0
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)
How can I fix this?
you need to upgrade the JRE you're running it with - the jar is compiled with 1.8

Exception in thread "main" java.lang.NoClassDefFoundError Shown in spite of having respective .class files in the directory

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

junit gives error java.lang.NoClassDefFoundError: junit/framework/JUnit4TestAdapterCache

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.

kettle startup inUbuntu

When I want to start Kettle:
$ cd ../kettle/data-integration
$ spoon.sh
The following error appears:
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Exception in thread "main" java.lang.NoClassDefFoundError: org/pentaho/ui/xul/XulEventSource
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:128)
Caused by: java.lang.ClassNotFoundException: org.pentaho.ui.xul.XulEventSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
What's wrong? Can anyone help?Many thanks.
Kettle is currently (5.0) supported using Java 7, please try with JDK or JRE 7
That class should be in the pentaho-xul-core jar located in your lib folder, there's a pretty serious problem with your classpath if it can't be found
Please edit spoon.sh to echo the command it's about to run on the last line (add "echo " at the beginning of the last line, exclude the quotes) and post what it comes out with.

Runtime error upon running compiled Groovy code in IntelliJ IDEA 13

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.

Categories

Resources