I am using Linux Ubuntu 13.10
I am trying to run a script and get the following error:
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar: Success
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
I have:
javac -version
javac 1.7.0_51
java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.10.1)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
When I run:
echo $CLASSPATH: I get blank output
echo $JAVA_HOME: blank output
Please help me, how to resolve this.
You have to set your CLASSPATH and JAVA_HOME environment variables. Take a look at this:
https://askubuntu.com/questions/186693/how-set-classpath-variable-for-a-folder-in-ubuntu
http://www.wikihow.com/Set-Up-Your-Java_Home-Path-in-Ubuntu
This could be useful as example, replacing the directories by yours:
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386/bin"
export CLASSPATH=".:/usr/lib/jvm/java-7-openjdk-i386/lib"
After you compile your code, you end up with .class files for each class in your program. These binary files are the bytecode that Java interprets to execute your program. The NoClassDefFoundError indicates that the classloader, which is responsible for dynamically loading classes, cannot find the .class file for the class that you're trying to use. It probably indicates that you haven't set the classpath option when executing your code. This link explains how to set the classpath when you execute
Related
I'm trying to install RapidMiner Studio and I'm having problems related with Java, running the installation file RapidMiner-Studio.sh in my terminal (OS Ubuntu 18.04). I think I have all the requirements to install RapidMiner. I found out I had to have Java 8 or OpenJDK 8, so I installed and configured as explained here. Also, from the same source's suggestions, I added this in the .sh file: --add-modules=java.xml.bind (after eval \"$JAVA\"). Like this:
if [ $# -gt 0 ]; then
eval \"$JAVA\" --add-modules=java.xml.bind $JVM_OPTIONS -cp \"${rmClasspath}\" com.rapidminer.launcher.GUILauncher \"$#\"
else
eval \"$JAVA\" --add-modules=java.xml.bind $JVM_OPTIONS -cp \"${rmClasspath}\" com.rapidminer.launcher.GUILauncher
fi
My OpenJDK version is this:
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
So, the errors I got from the installation file (after doing chmod +x RapidMiner-Studio.sh and ./RapidMiner-Studio.sh) are the following:
Error: Could not find or load main class com.rapidminer.launcher.JVMOptionBuilder
Unrecognized option: --add-modules=java.xml.bind
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
It's clear it doesn't recognize the added module java.xml.bind.
So without that added module in the .sh file, I removed it. And running, I got the following errors:
Error: Could not find or load main class com.rapidminer.launcher.JVMOptionBuilder
Error: Could not find or load main class com.rapidminer.launcher.GUILauncher
How can I solve this Java problem?
Thank you for your attention.
I'm answering my question. So, to solve this, I simply had to replace the original line rmClasspath="${RAPIDMINER_HOME}"/lib/* with rmClasspath=./lib/*. This wasn't about the Java, but really the shell script. I had defined RAPIDMINER_HOME previously and somehow itwasn't reconized in that if statement.
When I try to run apache gora compiler using ./gora goracompiler, I m getting the following error
Error: Could not find or load main class org.apache.gora.compiler.cli.GoraCompilerCLI
Before that I got JAVA_HOME not set error after that I resolved that error by setting JAVA_HOME variable
OS: Cent OS 6.5
Java version : java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
goracompiler command expects GoraCompilerCLI to be in $GORA_HOME/gora-compiler-cli/target/classes/
Check you have gora-compiler-cli/target/classes/java/org/apache/gora/compiler/cli/GoraCompilerCLI.class or the .jar from the module gora-compiler-cli in the classpath.
If not, compile the module with:
mvn package -pl gora-compiler-cli
I'm using Ubuntu and trying to install storm but got this
checking for jni.h in /usr/lib/jdk1.6.0_36/include... configure: error: cannot find jni.h in /usr/lib/jdk1.6.0_36/include.
when used this command
./configure
in JZMQ installation
java -version
java version "1.6.0_36"
OpenJDK Runtime Environment (IcedTea6 1.13.8) (6b36-1.13.8-0ubuntu1~14.04)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
i tried to edit in configure by used
sudo gedit configure
but same problem
tried to edit bashrc i added this line at the end of the file
export JAVA_HOME=/usr/lib/jvm/
but problem still
openjdk is in this path /usr/lib/jvm/java-6-openjdk-amd64
any solution ? why i got this error ?
At least you should have export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64 if you want to use this openjdk distribution.
Finally your configure/make should try to find jni.h in /usr/lib/jvm/java-6-openjdk-amd64/include
So, if you have an access to this property for "configure" - you can just change it to this value (of course, check before that file by this path actually exists)
Finally during "make" phase this path should be used this way:
gcc -I/usr/lib/jvm/java-6-openjdk-amd64/include ...
i am new to java & Linux, i have a problem regarding setting PATH in kali linux to run Java Programs, i have set the path as shown below after that i have executed the basic commands of java like java-version, javac, but when it comes to compile a java program it is showing the error as:& also why it is showing lower version of java, though even i have installed latest version of Java i.e JDK1.8.0_31, TIA
root#kali:~# PATH=/home/opt/jdk1.8.0_31/bin:$PATH
root#kali:~# export PATH
root#kali:~# java -version
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-2~deb7u1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
root#kali:~# javac
root#kali:~# javac Hello.java
javac: file not found: Hello.java
It is well set. The error message is exactly what is happening. The file is not there.
I uninstalled java j2sdk1.4.2_12 java on my Linux Server and Install jdk1.6.0_21,
but when I am trying to run any script I am getting following Error
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.
I already set classPath and Path like :
In vi ~/.bashrc
export JAVA_HOME=/home/java/jdk1.6.0_21/
export PATH=$PATH:/home/java/jdk1.6.0_21/bin
export set CLASSPATH=/usr/java/j2sdk1.4.2_12/lib/mysql-connector-java-5.1.6-bin.jar: /home/java/jdk1.6.0_21/jre/lib:/root/mis/mod:$CLASSPATH
ulimit -c unlimited
IN vi ~/.bash_profile
JAVA_HOME=/home/java/jdk1.6.0_21/
PATH=$PATH:$HOME/bin:$HOME/mis/mod:
PATH=/home/java/jdk1.6.0_21/bin:$PATH
CLASSPATH=$CLASSPATH:/home/java/jdk1.6.0_21/lib:.:
export JAVA_HOME
export PATH
export CLASSPATH
unset USERNAME
When I run following Commands
which java
/home/java/jdk1.6.0_21/bin/java
java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)
I am not getting where is the issue.
Can Any one help me ?
I encounter this issue before. It turns out there are 2 javac program sitting on my machine.
They are in /usr/bin/javac and /bin/javac. My system used the /bin/javac one. The right path for me is /usr/bin/javac. Removing /bin/javac helped
I faced the same issue, and it disppeared by just shutting down the CentOS VM and then starting again. Then type in javac command again to check.