My vitals: OS 10.7.5 Lion, Java version "1.7.0_79", Maven version 3.0.3.
I'm quite new to Environment Variables here, and having a lot of trouble with Maven. I got my current version from Homebrew, but I need a more recent one. I followed snooze92's instructions from this page (Maven Install on Mac OS X) to try to install the latest version of Maven, 3.3.3. My current version, 3.0.3, is stored in /usr/share/java/maven-3.0.3, and there's also a shortcut to that directory at /usr/share/maven.
echo $JAVA_HOME returns /System/Library/Frameworks/JAVAVM.framework/Versions/CurrentJDK/Home.
But running mvn --version returns a bunch of details including:
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre (which is a different folder to the path JAVA_HOME points to.)
Normally, echo $M2_HOME returns nothing. In this case, Maven 3.0.3 works just fine. If I create the $M2_HOME environment variable, as snooze92 suggests, and add it to my path using the following commands:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
Maven stops working; typing in mvn --version returns the following:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Quitting Terminal (or deleting the above lines from my .bash_profile file and re-opening) makes Maven work fine again, although it always reverts to version 3.0.3.
I also tried adding the commands on this page (http://www.mkyong.com/maven/install-maven-on-mac-osx/) to my .bash_profile file:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.3
export PATH=$PATH:$M2_HOME/bin
This causes Maven to return the error message:
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
You could edit your .bash_profile to export the dynamic path of your JDK 7 Mac OS installation. This can simply be achieved by adding as first line:
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
Thereby, it should be guaranteed that no 1.6 style JDK (e.g., as delivered by Apple) is used at runtime, but a working JDK 7 of your system environment. Try to validate the output of
java -version
in a new terminal instance after you edited the .bash_profile file. It should give you 1.7.x Java. After this step your newer Maven version should work and can be validated via
mvn -version
Explanation:
If you use /System/Library/Frameworks/JAVAVM.framework/Versions/CurrentJDK/Home instead you will get something like this for your JAVA_HOME:
java version "1.6.0_65" Java(TM) SE Runtime Environment (build
1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
which is not what you want/need for Maven 3.3.x
Related
I try to compile https://github.com/CuriousNikhil/k5-compose in IntelliJ, I got the below error
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61326:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/tools.jar:/Users/elisha.lye/Development/experiment/k5-compose/build/classes/kotlin/main:/Users/elisha.lye/Development/experiment/k5-compose/k5-compose/build/classes/kotlin/main:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.21/6b3de2a43405a65502728047db37a98a0c7e72f0/kotlin-stdlib-jdk8-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.21/f059658740a4b3a3461aba9681457615332bae1c/kotlin-stdlib-jdk7-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.21/2f537cad7e9eeb9da73738c8812e1e4cf9b62e4e/kotlin-stdlib-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.desktop/desktop-jvm/1.0.0-alpha3/7d2ec16f4e057de47d41ffc5c8416f9f85aeab3e/desktop-jvm-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.21/cc8bf3586fd2ebcf234058b9440bb406e62dfacb/kotlin-stdlib-common-1.5.21.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.material/material-desktop/1.0.0-alpha3/60d4a46d2ee31e82ab61342887203b23aee0ba83/material-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.foundation/foundation-desktop/1.0.0-alpha3/29c590b69d13ec16352497848d1bf05da1de062e/foundation-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-desktop/1.0.0-alpha3/7f33f2592490b6d23494c0842d6f15ac592f9bb7/ui-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-tooling-preview-desktop/1.0.0-alpha3/4676c56ea7defd68facfab054079ac1e76aba57f/ui-tooling-preview-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.runtime/runtime-desktop/1.0.0-alpha3/481c6e0d45e192d4f02f993e049262e0668f6018/runtime-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-swing/1.5.0/f9702179f0e36a0541ffe77a7a62596c4fc6ad83/kotlinx-coroutines-swing-1.5.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.2.0/57136ff68ee784c6e19db34ed4a175338fadfde1/annotation-1.2.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.material/material-ripple-desktop/1.0.0-alpha3/ffc54fa1f9c6e164d6ccdd53f7411bd80ccbce6c/material-ripple-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.material/material-icons-core-desktop/1.0.0-alpha3/3e869bc14a82c27647e3719579d6acb517d2fc2a/material-icons-core-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.animation/animation-core-desktop/1.0.0-alpha3/ec648418e6980b80f376f2b0455d5e2ba74f0445/animation-core-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-text-desktop/1.0.0-alpha3/c1706e1e249c65fe08a672f3ab8f442ee864cf59/ui-text-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.animation/animation-desktop/1.0.0-alpha3/eeff15e8d42d2fab8e6fb4eb0356ae397070aa49/animation-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.runtime/runtime-saveable-desktop/1.0.0-alpha3/1b7a4801b28b5541d87cd9ae560571a77cc94dd/runtime-saveable-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-graphics-desktop/1.0.0-alpha3/f3b1bfc01b7316e6d5af522b1025fe09f7fff137/ui-graphics-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-unit-desktop/1.0.0-alpha3/5cefe80c330e154436abdb12825a828229ed950f/ui-unit-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-geometry-desktop/1.0.0-alpha3/261a169b4e2816397d8c4e22e63a2d590f99210a/ui-geometry-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.0/d8cebccdcddd029022aa8646a5a953ff88b13ac8/kotlinx-coroutines-core-jvm-1.5.0.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.skiko/skiko-jvm/0.3.9/8b3108a3fb80baa30163d20d8176f108d895b44f/skiko-jvm-0.3.9.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.foundation/foundation-layout-desktop/1.0.0-alpha3/878f19bd721b99f677e959d96595573f8198eb1c/foundation-layout-desktop-1.0.0-alpha3.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.skiko/skiko-jvm-runtime-macos-x64/0.3.9/7dd5c3ab33897ea23d4e46251a7d04515755d0dd/skiko-jvm-runtime-macos-x64-0.3.9.jar:/Users/elisha.lye/.gradle/caches/modules-2/files-2.1/org.jetbrains.compose.ui/ui-util-desktop/1.0.0-alpha3/6de31edde97babd7339e67bb1b82ebff1a805e9c/ui-util-desktop-1.0.0-alpha3.jar MainKt
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: MainKt has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
This is clearly because it needs Java 11, and it got compiled in Java 8.
However, when I check all places I see, they are all set to Java 11. The below is what I have checked
1. In the Terminal environment
java -version
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)
elisha.lye#C02FF0VFQ05N k5-compose %
2. In the Gradle setting
3. In the Java Compiler
4. In the JRE Setting
Where do I miss setting my Java Run Time?
1 - Is for your OS and terminal, nothing common with the project
2 - Is the JDK for running Gradle. For Gradle daemon itself, not for the project
3 - Is the project's bytecode version which could be overwritten in module.
4 - Is the Runtime environment for the IDE itself.
So, you need to edit Project Structure > Project setting > Project > Language level See https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk
[Edit Configurations...] or [Modify Run Configuration...] menu to open the "Run/Debug Configurations" dialog.
Select the runtime version from the [JRE:] drop-down menu.
I have downloaded the ant-media-server files and tried to launch the server.
But, I recently learned that Ant Media Server requires java 11.
So I updated the java version to java 11:
So when I run this command:
java -version
This is the result:
openjdk version "11.0.11-ea" 2021-04-20
OpenJDK Runtime Environment (build
11.0.11-ea+4-Ubuntu-0ubuntu3.16.04.1)
OpenJDK 64-Bit Server VM (build 11.0.11-ea+4-Ubuntu-0ubuntu3.16.04.1,
mixed mode, sharing)
And when I run this command:
javac -version
This is the result:
javac 11.0.11-ea
When I try to launch the Ant Media Server, this is the result I get:
Bootstrap exception: null
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.red5.server.Bootstrap.bootStrap(Bootstrap.java:122)
at org.red5.server.Bootstrap.main(Bootstrap.java:50)
Caused by: java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path: [/home/ahmed/Desktop/CodingPlayground/ant_media_server/ant_media_server/lib/native]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2670)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1873)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1683)
at org.bytedeco.javacpp.Loader.load(Loader.java:1300)
at org.bytedeco.javacpp.Loader.load(Loader.java:1123)
at org.bytedeco.ffmpeg.global.avutil.<clinit>(avutil.java:14)
at org.red5.server.Launcher.launch(Launcher.java:65)
... 6 more
Caused by: java.lang.UnsatisfiedLinkError: /home/ahmed/.javacpp/cache/ffmpeg-4.3.1-1.5.4-linux-x86_64.jar/org/bytedeco/ffmpeg/linux-x86_64/libjniavutil.so: libva-drm.so.2: cannot open shared object file: No such file or directory
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1837)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1633)
... 10 more
Any idea what's going on?
EDIT 1:
When I checked the JAVA_HOME environment variable, I found-out, it still points to java-8 files:
JAVA_HOME=/usr/lib/jvm/java-8-oracle
So I tried to see the files in /usr/lib/jvm, and this is what I found:
So maybe this is causing the problem?
I don't know to which file should I make JAVA_HOME point to instead.
EDIT 2:
I opened /etc/environment and modified JAVA_HOME to this:
JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64'
I also changed it globally by running:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
And, I am still getting the same error.
check variables in /etc/profile
you may set java environment strong textvariables like this:
export JAVA_HOME=/usr/share/jdk1.6.0_14
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
I've set up a job in Jenkins that runs ant, it gives this error:
First time build. Skipping changelog.
Unpacking https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.3-bin.zip to /var/lib/jenkins/tools/hudson.tasks.Ant_AntInstallation/default-ant on Jenkins
[my_project] $ /var/lib/jenkins/tools/hudson.tasks.Ant_AntInstallation/default-ant/bin/ant dist
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/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:442)
at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Build step 'Invoke Ant' marked build as failure
Why is this happening ?
What can I do to fix it ?
Note,
If I ssh in to the build server, go to the jenkins workspace, and manuall run
/var/lib/jenkins/tools/hudson.tasks.Ant_AntInstallation/default-ant/bin/ant dist
the build succeeds.
Jenkins reports java.runtime.version 1.8.0_131-b11 and on the build machine:
# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
I found the issue, as hinted by in the comments by #VeselinDavidov
The newest ant (v 1.10 and newer) only supports Java 8, however the $PATH was set to include a place with Java 7 (unknown as to why JDK 7 was the 1. item in the $PATH when ant was run through jenkins, but not when running it manually outside jenkins)
To resolve:
Go to the configuration of the job in Jenkins
Go to the "Build Environment" section
Check the "With ant" checkbox which also expands to more configuration options.
Select the proper "Ant version" and "JDK version"
If the proper "JDK version" is not available/installed, do this first:
Go to "Manage Jenkins" from the jenkins front page
Go to "Global Tool Configuration" and click "JDK Installations"
Define/install the relevant JDK version.
Go back to the job and set up ant with this new JDK version.
Alternatively, if Java 7 is sufficient, install and use ant version 1.9.x, which supports Java 7.
Following the solutions online for Major Minor version of Java being incorrect on El Capitan, I saw several solutions which made you either disable rootless, which i didn't like the sound of, or just didn't work anymore in OS X El Capitan.
When trying to run webdriver-manager start on El Capitan, you may get an error saying:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Selenium Standalone has exited with code 1
The recommended fix for this online is to change the symlink that Mac OS X has to Java, which you can find by running echo $JAVA_HOME in the terminal.
This is pointing to the incorrect folder, and the error is because the application was compiled with a higher version of JRE than the machine is running in the terminal.
You should go to Oracle, and download the latest JRE version (http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
After this has been installed, you will have Java 8 on your machine, but it will not update the terminal properly. If you run java -version in your terminal, you'll see Java Version "1.6", you want this to say Java Version "1.8". The previous way to do this was to change the symlink manually, however, since El Capitan, Apple have made certain folders unchangable even to admin users, with their Rootless install. This includes the /usr folder.
There are two ways to fix this, the first is dangerous, and what everyone else seems to recommend. The second, is safer, and what I am putting here.
If you go to your System Preferences -> Java -> Java -> View... -> System and copy the Path field.
It will look something similar to the following:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
We want most of this path, except the /bin/java on the end.
So your path should now be copied as:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Run the following command in the terminal, replacing [PATH] with the path you have from above.
export JAVA_HOME="[PATH]"
and run that in the terminal.
Afterwards, run java -version again, and it should now say Java Version "1.8"
Now, webdriver-manager start should succeed.
Adding the following line to ~/.bash_profile worked for me:
export JAVA_HOME="$(/usr/libexec/java_home --version 1.8)"
You might have to restart your shell for these changes to reflect or just run:
. ~/.bash_profile
I'm using Spring Tool Suite (basically the same as Eclipse, can't actually find a difference but I'm being made to use it) for an assignment and I'm having an error when I right click on the project and click 'Run As -> Maven Install'.
Exception in thread "main" java.lang.UnsupportedClassVersionError:
org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClassCond(ClassLoader.java:637) at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at
java.net.URLClassLoader.access$000(URLClassLoader.java:58) at
java.net.URLClassLoader$1.run(URLClassLoader.java:197) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:190) at
org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at
org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at
org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at
org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at
org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at
org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Everything else I have found on stack exchange implies that this is something to do with the Java Version, but I can't figure out how I have it wrong. When I run mvn -version on terminal I get
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T21:57:37+10:00)
Maven home: /usr/local/Cellar/maven/3.3.3/libexec
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.4", arch: "x86_64", family: "mac"
When I run java -version I get
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
I tried setting JAVA_HOME (as per Maven Installation OSX Error Unsupported major.minor version 51.0) and it is set to the correct path.
My STS settings say it's compiling using 1.8, and running using 1.8, and the properties of the project say it's compiling using 1.8 too. I don't understand where the problem is.
I originally tried changing everything to Java 1.7 to see if that was the problem but it still didn't help. I changed it back to 1.8 in the end because that's what the rest of my group are using.
This is my first post so I can't post screenshots, they're at the link.
http://imgur.com/a/al7go
I fixed it by deleting Java SE 6 from the Installed JREs list in screenshot 1. Even though 8 was selected, it was still using 6 for some reason.
I faced the same issue, by removing .m2 repository or just renaming it, resolves the issue
you should config JRE when execute maven build