I had a homework assignment which is to be done using OpenMp, but I'm not a good c/c++ programmer, so I decided to do it in java using the JOMP API.
Anyway, I have a problem running the hello world program. I did all the steps showing in this link but I'm still getting this error when I try to compile:
java jomp.compiler.Jomp Hello
I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: jomp/compiler/Jomp
Caused by: java.lang.ClassNotFoundException: jomp.compiler.Jomp
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: jomp.compiler.Jomp. Program will exit.
I use ubuntu 11.10 jdk 6
Exception in thread "main" java.lang.NoClassDefFoundError: jomp/compiler/Jomp
In general this exception occurs if jar file is not in runtime classpath. Make sure you have add jomp.jar (Don't know exact jar name, use valid jar) which has jomp/comipler/Jomp class to classpath.
Related
I'm attempting to run Apache Ant for the purpose of compiling OpenGTS. While attempting to run any "ant" command I'm getting the following output:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.apache.tools.ant.launch.Launcher. Program will exit.
Previously I was getting a message stating "JAVA_HOME is not defined correctly" and after reading several forum threads, was able to solve that by updating the path:
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
Another thread stated a "CLASS PATH" issue but if I'm able to run "ant" anywhere in the terminal, wouldn't the path be correct? Thanks in advance.
Make sure to set ANT_HOME to the directory where you installed ant. Refer to Installling Apache Ant.
You need to export ANT_HOME too, just make sure it is installed first on your system
export ANT_HOME="/usr/local/ant";
In my case it was a wrong permission on /opt/ant/lib folder.
I was having trouble with a could not find main class error with a somewhat complicated program I was working on. To eliminate possible problems I decided to try a hello world program to see if I could get that to work. I am working on a server which I'm pretty sure is running Red Hat Enterprise 6. I followed these steps provided by Bart Kiers in answer to this question:
create a file called HelloWorld.java;
paste the code posted below
inside HelloWorld.java: compile it by executing the command: javac
HelloWorld.java in the same folder as HelloWorld.java is in;
execute the code by doing: java -cp . HelloWorld in the same folder as
HelloWorld.java is in.
I get the following error after the last step:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/
Caused by: java.lang.ClassNotFoundException: HelloWorld.
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: HelloWorld.. Program will exit.
If I type java -version, the version info displays, suggesting that my PATH variable is set correctly. Does anyone have any other suggestions for things that might be causing this error? Thanks!
Looks like you are putting an period at the end of your class name:
java -cp . HelloWorld.
Do this instead
java -cp . HelloWorld
I have uploaded two screen shot which are related to my java. When I try to compile a java file, it compiles the java file correctly and creates the .class file successfully, but when I try to run the compiled file it gives an error message. I have attached two screen shots which are related to this problem. Please help me.
Here is the stack trace that I get trying to run with java Test command:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Test : Unsupp
orted major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessControll.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Test. Program will exit.
and with java Test.javacommand:
Exception in thread "main" java.lang.NoClassDefFoundError: Test/java
Caused by: java.lang.ClassNotFoundException: Test.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessControll.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Test.java. Program will exit.
You have two issues. The first, as mentioned by #davidfmatheson, is that you have compiled the program under one version of Java and are trying to run it in another. You either need to recompile in Java 6, or run it in Java 7.
The second issue is with your command line. When you compile, you need to pass javac the filename, including the extension, but when you run it, java takes the name without the extension:
> javac Test.java
> java Test
This is the source of the NoClassDefFound error.
The version number of 51.0 means that you've compiled with JDK 1.7. Check which javac from your command-line. Then you try to run it using java Test with a Java that's evidently version 1.6. Find out where your JDK 1.6 is located, ensure that the javac in 1.6 comes first on the PATH, and recompile your Test class.
I'm trying out OpenNI for Kinect and got it to install and run sample code according to
this guide. But now, I want to modify the code and compile it and test it. However, I'm not sure how to compile and run on Linux. I found a guide here that does it for Windows, but can't seem for the life of me to find anything for Linux.
I did try adapting the Windows code for Linux and tried
javac -cp ~/kinect/OpenNI/Samples/Bin/x86-Release/org.OpenNI.jar VersionInfo.java
java -cp ~/kinect/OpenNI/Samples/Bin/x86-Release/org.OpenNI.jar VersionInfo
but it gives me
Exception in thread "main" java.lang.NoClassDefFoundError: VersionInfo
Caused by: java.lang.ClassNotFoundException: VersionInfo
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: VersionInfo. Program will exit.
Any ideas on how I can compile and run my java code onto the Kinect? If you know how to do it for the Samples in the OpenNI folder, that would be perfect.
Nevermind, figured it out. Turns out I needed to learn about make and Makefiles and how they're used to compile .java files into a .jar.
Hello Guys I am trying to figure out why i am gettings this error when I am trying to run this API from Shell on my linux System.
[~/public_html/test/]# java -jar jodconverter-cli-2.2.2.jar Amritpal.doc sample.pdf
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: com.artofsolving.jodconverter.cli.ConvertDocument. Program will exit.
You need to do this in order to include the Apache Commons CLI library in your classpath:
java -cp '.:/path/to/cli.jar' -jar jodconverter-cli-2.2.2.jar x.doc y.pdf
If you're on Windows, use a semicolon ; instead of the colon : in specifying the classpaths.
Because you don't have the dependencies specified in the classpath (The first one being exactly what the error is telling you, the apache.commons.cli library).
You either need to specify them on the command line or in the manifest in that jar.