STS: run as -> maven install error - java

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

Related

How to set JRE or JDK to Java 11 for IntelliJ when I get error "compiled by a more recent version of the Java Runtime (class file version 55.0)..."

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.

Ant gives "Unsupported major.minor version 52.0" when run through Jenkins

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.

Can't upgrade Maven on Mac Lion - Environment Variables

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

Unable to analyse project with SonarQube

I want to analyse project with SonarQube
while doing this it gives me a error message saying
Error during execution of Sonar
Error status [command: C:\Program Files (x86)\Java\jdk1.6.0_18\jre\bin\java.exe -cp C:\Users\qfrg\AppData\Local\Temp\sonar-runner-impl7722306846094038579.jar org.sonar.runner.impl.BatchLauncherMain C:\Users\qfrg\AppData\Local\Temp\sonar-project6654886318444556353.properties]: 1
In the console log i see this :
Caused by: org.sonar.api.utils.SonarException: The plugin javascript is not supported with Java 1.6.0_18
Caused by: java.lang.UnsupportedClassVersionError: org/sonar/plugins/javascript/JavaScriptPlugin : Unsupported major.minor version 51.0
I installed plugins for findbugs, checkstyle, PMD and M2Eclipse successfully before installing sonarqube, but after installing sonarqube, when i tried to add them again they say that
Unable to connect to repository http://eclipse-cs.sourceforge.net/update/compositeContent.xml
Connection to http://eclipse-cs.sourceforge.net refused
Please find my version and plugin details:
java:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
maven:
Apache Maven 3.0.3 (r1075438; 2011-02-28 23:01:09+0530)
Maven home: C:\dev\apache-maven-3.0.3-bin
Java version: 1.6.0_18, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_18\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
and
SonarQube Server 4.5.4
Eclipse : Kepler Service Release 2
And i am using TFS as source control
Where am i going wrong ?
Is this the problem with java version ? As, I have seen in some sites that it worked for them when upgraded to 1.7 version of java
Any help greatly appreciated
As mentionned in the Requirements documentation page, Java 7 at least is required to run SonarQube server and SonarQube analyses.
You are using a Java 6 virtual machine, this is why you get those error messages.

UnsupportedClassVersionError on hadoop with no apparent change of version

I'm running a hadoop job on my university cluster, which is failing with the following error:
hadoop jar target/SpamClassifier-1.0-SNAPSHOT-jar-with-dependencies.jar <args>
Exception in thread "main" java.lang.UnsupportedClassVersionError: infolab/social/spam/FeatureApp : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.hadoop.util.RunJar.main(RunJar.java:205)
I've done a bit of reading, and it looks like this can be because the jar is compiled with a version of java that is different to the runtime version. I tried building on the hadoop master itself (because I enjoy the luxury of permissive shell access to the machine), but it was to no avail.
Java version:
$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Maven version:
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 09:22:22-0600)
Maven home: /opt/apache-maven-3.1.1
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-431.5.1.el6.x86_64", arch: "amd64", family: "unix"
Hadoop version (Hortonworks):
$ hadoop version
Hadoop 2.2.0.2.0.6.0-102
Subversion git#github.com:hortonworks/hadoop.git -r 02ad68f19849a0a986dac36b705491f6791f9179
Compiled by jenkins on 2014-01-21T00:56Z
Compiled with protoc 2.5.0
From source with checksum 66f6c486e27479105979740178fbf0
This command was run using /usr/lib/hadoop/hadoop-common-2.2.0.2.0.6.0-102.jar
I am building all of this with maven, and below is the excerpt from my pom.xml that specifies java versioning:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
I really at a loss. Could it be that maven is compiling using a different version of java for some reason? I didn't think we even had a different version installed.
I think you have more than one version of java installed or some version previously installed on your system and the other one comes with hadoop if any.
You are compiling with one and launching with other.
Copy the contents of the environmental variable PATH settings to a text and check the locations for the installed versions on the PATH. If so, remove one of them and save the PATH.
You could also check your maven settings, where it should clearly show set JAVA_HOME
You could also:
Remove automatic build
Clean project
Build with maven: maven -> build
Thanks to everyone for the help. The source of the problem was the hadoop configuration, which was overriding my JAVA_HOME. Hadoop configures a custom environment in its hadoop-env.sh configuration file. Mine had been improperly configured with the line:
export JAVA_HOME=/usr/jdk64/jdk1.6.0_31
This was a result of our using the Hortonworks hadoop suite, which utilizes Ambari and sets up an independent jdk distribution on initial setup. After upgrading our version of hortonworks and reconfiguring it, our mapreduce jobs are functioning correctly.

Categories