Perhaps you are running on a JRE rather than a JDK [duplicate] - java

This question already has answers here:
Compilation error in building maven project
(3 answers)
Closed 3 years ago.
I'm running Jenkins on EC2 Suse Linux and have a Jenkins job which gives me following error:
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/sampleMulti_develop/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
I verified JAVA_HOME by which java shows: /usr/bin/java, gave same path in global tool configuration. Am I missing something here?

Probably you have only the Java Runtime Environment installed (JRE).
For running Jenkins, you need the Java Development Kit (JDK) which contains the javac binary for compiling Java code.
I am no expert in SuSe but I think you can install Open JDK using this link.

Related

Java compiled with newer JDK does not run in older Java [duplicate]

This question already has an answer here:
java.lang.UnsupportedClassVersionError org/springframework/boot/loader/JarLauncher has been compiled by a more recent version of the Java Runtime
(1 answer)
Closed 3 months ago.
I wrote a fairly simple spring boot application in Java. I am on Windows, using latest intelliJ, Maven, and JDK 17. Have configured my compiler source and target to Java 11
My understanding is that I should be able to run this app in Java 11. But when I run in Java 11, I get error below:
Error: LinkageError occurred while loading main class
com.my.org.application.tester.Runner
java.lang.UnsupportedClassVersionError: org/springframework/boot/CommandLineRunner has been compiled by a more
recent version of the Java Runtime (class file version 61.0), this
version of the Java Runtime only recognizes class file versions up to
55.0
I tried using Java 11 to compile but get this error when I compile:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
(default-compile) on project passport-tester: Compilation failure
I am consuming spring-boot-autoconfigure 3.0.0. Have confirmed my jdk settings are correct. When running in JDK 11 I have set JAVA_HOME, path, CLASSPATH to point to JDK11 folder
Is there any other setting I am missing, or should I check to make this work?
From https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Release-Notes :
Spring Boot 3.0 requires Java 17 as a minimum version.

Updating java JRE to match what is compiled with JDK [duplicate]

This question already has answers here:
How can I get Java 11 run-time environment working since there is no more JRE 11 for download?
(4 answers)
Closed 3 years ago.
I'm trying to run a java application that I have compiled using the IntelliJ IDEA, by the commandline running the following command:
java myApp.Main
This gives me the following error:
"Exception in thread "main" java.lang.UnsupportedClassVersionError: FlightConverter/Main 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"
In IntelliJ the JRE set to run in the run configuration is: /Java/jdk-11.0.3, but I get the error above when I try to run it. When i type java -version in cmd I get "1.8.0_211"
I cant really seem to find out how to update my current JRE to match what is used by the compiler either? It seems I'm only able to find JRE 8.xx online
I'm sure you can get location of java 8 from local system and set that as a compiler in IntellIJ IDE.. This way both your system and IDE works only on Java 8 and everything will work fine...
Hope this helps...

Gradle can't find tools.jar [duplicate]

This question already has answers here:
Gradle does not find tools.jar
(30 answers)
Closed 4 years ago.
I found this post but the answer did not solve my problem. The answers only address windows systems and provide file paths which are not helpful for the OS I am running.
I am running openSUSE Leap 15 with Java 1.8, changing the OS or Java version is not an option.
When I try to build with the command ./gradlew clean build i get the following error:
:buildtools:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildtools:compileJava'.
> Could not find tools.jar. Please check that /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre contains a valid JDK installation.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15.364 secs
I have checked my Java installation like this:
$> rpm -qa | grep java
javapackages-tools-5.0.0+git20180104.9367c8f6-lp150.1.2.x86_64
timezone-java-2018g-lp150.2.13.1.noarch
java-1_8_0-openjdk-1.8.0.181-lp150.2.6.1.x86_64
libjavascriptcoregtk-4_0-18-2.20.5-lp150.2.6.1.x86_64
java-1_8_0-openjdk-headless-1.8.0.181-lp150.2.6.1.x86_64
I also checked out JAVA_HOME:
$> echo $JAVA_HOME
/usr/lib64/jvm/jre-1.8.0-openjdk
The comments inspired me to find a solution. Apparently installing the package java-1_8_0-openjdk will only provide the OpenJDK 8 runtime environment. I wrongly expected it to include the development tools because of the 'jdk' in its name (Java Development Kit).
My problem was solved by simply installing the package java-1_8_0-openjdk-devel which actually includes the development tools, like this: sudo zypper in java-1_8_0-openjdk-devel.
The command zypper se jdk can help you to figure out the status of your jdk installation. After installing the package java-1_8_0-openjdk-devel you should see an i+ next to the package name. You should be able to spot the following two lines:
i+ | java-1_8_0-openjdk | OpenJDK 8 Runtime Environment | package
i+ | java-1_8_0-openjdk-devel | OpenJDK 8 Development Environment | package

Unable to locate the Javac Compiler using jre8

I upgraded from Java7 to Java8
JAVA_HOME is C:\Program Files (x86)\Java\jre8
I am trying to run maven install on a plugin and I get the following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project IcrMappingReport: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files (x86)\Java\jre8\..\lib\tools.jar
In all the projects I updated the JRE System Library to jre8 and also in
Windows -> Preferences -> Java -> Installed JREs to C:\Program Files (x86)\Java\jre8
Can anyone tell me the problem?
You need the Java8 JDK not the JRE.
JDK stands for Java Development Kit, (includes Compiler)
JRE stands for Java Runtime Environment, so it's just for running Java Programs.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Compiler is included in JDK, not JRE.
You need a JDK in order to compile java source code.

java.lang.UnsupportedClassVersionError: [duplicate]

This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 6 years ago.
I have developed a small project in eclipse which makes use of Java6. But I want to run the same project in hpux system which has java1.5. When I try to run it is throwing the error :
java.lang.UnsupportedClassVersionError:.
Then I have changed the eclipse Java compiler to java1.5 and jre to 1.5.0_12 then recompiled my project. After that I have deployed once again in hpux system but still it is throwing the same error. I used ant to compile in hpux system. It compiled successfully and produced jar. But while running it is throwing the same error.
Any help is highly appreciated.
Many Thanks in Advance.
You can use the target config option with a value of 1.5 so that the compiled classes are compiled to run against JVM 1.5. Also, make sure that 1.5 is the correct jvm on hpux by manually running java -version.
Read more details here
Use the cross-comilation options when compiling, specifying a source/target of 1.5, and a bootclasspath pointing to a 1.5 rt.jar

Categories