I am running into below error while launching an agent on my Jenkins 2.107.2 ,looks like this is a popular error and based on my homework it sounds like need to launch the agent using 1.8,I installed 1.8 and my /usr/lib/jvm folder looks like below,however when I launch the agent it still using java 1.7.0, how do I force Jenkins to launch the agent using 1.8?
/usr/lib/jvm
Error:
[05/02/18 10:17:59] [SSH] Starting sftp client.
[05/02/18 10:17:59] [SSH] Copying latest slave.jar...
[05/02/18 10:17:59] [SSH] Copied 762,466 bytes.
Expanded the channel window size to 4MB
[05/02/18 10:17:59] [SSH] Starting slave process: cd "/home/username" && /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java -jar slave.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher : Unsupported major.minor version 52.0
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)
Slave JVM has terminated. Exit code=1
[05/02/18 10:17:59] Launch failed - cleaning up connection
[05/02/18 10:17:59] [SSH] Connection closed
You can explicitly set the path to the java executable in the node launch configuration:
Find the option JavaPath and set it to the full path to the java executable you want to use; like:
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java
Save