Good day to everybody!
I wrote simple program :
import java.lang.System;
public class hello{
public static void main(String[] args){
System.out.println("Hello World");
}
}
This is working fine if run it on local server. But i'm facing issue when i access this program remotely like this:
ssh remote_machine "java hello"
I'm getting below error:
Exception in thread "main" java.lang.NoClassDefFoundError: hello
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Caused by: java.lang.ClassNotFoundException: hello not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7rh)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
I found that it's becasue of incosistency of jvm version and code compiled java version.
Incosistency is happening because when i created and complied the code that machine is using java 1.5 , but when i remotely accessing it, it's using java 1.4 via "gij (GNU libgcj) version 4.1.2 20080704"
Question : is it possible to by pass "gij (GNU libgcj) version 4.1.2 20080704" and use initially used java version when i access it remotely?