I'm new at linux and java programming, I've been trying to run a test program but the only way for it to work is overwriting entirely the PATH. This is the path I've set in the .bashrc:
export PATH=:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/jdk-15.0.1/bin:
and the JAVA_HOME:
export JAVA_HOME=:/usr/lib/jvm/jdk-15.0.1:
When I run it like this, I get the following error: "Error: LinkageError occurred while loading main class FirstJavaProgram java.lang.UnsupportedClassVersionError: FirstJavaProgram has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
".
However, when I overwrite the path to just /usr/lib/jvm/jdk-15.0.1/bin
, it runs the program.
Do I have to set the PATH in a different way?
which java
can tell where the command is found – Thorbjørn Ravn Andersen Oct 29 '20 at 16:34