Which jvmTarget use for kotlin project? - gradle

I use kotlin to writing backend service with gradle and comple it for 1.8 jvm. Is it any reason to switch jvmTarget from 8 to 12 version?

This is highly based on your environment.
If you know your targeted/final environment will indeed be running Java 11+, then you can target Java 11+.
But if your environment is running Java 8, then you should target Java 8. And if you have other fellow developers that are on/stuck on Java 8, then you should probably target Java 8 as well.

Related

How do I get gradle 7 to work in IntelliJ IDEA?

I am having some troubles with setting up a project with gradle 7.1. I can't go below 7 because Fabric Loom 0.8+ needs gradle 7+.
The Intellij IDEA log: https://controlc.com/1c0be753
Using Gradle 7.1 and Java 16
See the related comment in IntelliJ IDEA bug tracker and this bug request on Gradle GitHub. The exception could be caused by the filesystem (FAT) and is fixed in Gradle 7.2

What version of java does gradle use to run your application?

I have a JavaFX project I am working on using Gradle. What version of java is used when I use the gradle run task from the application plugin?
In IntelliJ I can go into the Gradle settings and change the "Gradle JVM" to any version I want. Is this just the version of java that is used to run the build? Or is this also the version that my application will be run on?
Where does my JAVA_HOME come into this, if at all?
Irrespective of IDEs, Gradle will use whatever language level of the JVM that is running Gradle. Typically whatever the value is for JAVA_HOME.
See Environment variables and Targeting a specific Java version
The new way to do it as of Gradle 6.7 is to use Toolchains for JVM projects
Your IDE should respect whatever Gradle configuration that is configured.

How to add a JRE 1.8 into Eclipse Installer JRE?

I am trying deploy my Spring Boot application to Elastic Beanstalk.
The problem that I am facing right now is, my application is developed with Tomcat 9, Java 13 and Project Facet 4.0.
So when I deployed to a AWS environment, I kept getting error. After researching, I found out AWS only support Tomcat 8, Java 8 and Project Facet 3.0.
I managed to change Project Facet 4.0 to 3.0.
But I can't add Java 8 to the project.
I downloaded the JDK 8 from Oracle, and tried open jdk-8u251-macosx-x64.dmg and run JDK 8 Update 251.pkg.
The system keeps giving me error that: "JDK 8 Update 251.pkg" can't be opened because Apple cannot check it for malicious software. This software needs to be updated.
Anyone know how to fix this problem so that I can run JRE 8 on eclipse?
Here is picture the problem that I have when I deploy the app to AWS.
An internal error occurred during: Updating AWS Elastic Beanstalk environment
Here is the thread that I tried to follow but without success:
https://github.com/aws/aws-toolkit-eclipse/issues/149.
Can you elaborate where exactly are you seeing the error? While running the JDK package or while configuration the JDK within Eclipse?
Nevertheless, I suppose your main requirement is to get your Eclipse to use Java 8.
It can be done in multiple ways.
Usually you can change Java compiler level to 1.8 from Project Settings even if you're using Java 13.
If you're using Maven, you can specify compiler source and target to Java 1.8
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Alternatively, you can download the JDK 8 zip instead of installer, unzip to any location and use that in Window > Preferences > Java > Installed JREs. Be sure to mark that one as default JRE.

Wrong Major Version number when running Sonar Scanner with Java 11

I'm currently migrating a project from java 8 to java 11, and have been using Sonar scanner, with gradle, to send the code to SonaQube. After migrating to Open JDK 11, I amd getting the following error when running the gradle sonarqube tasks:
java.lang.IllegalArgumentException: Unsupported class file major version 55
I have read online that the scanner should be run with jdk 8, even though the analysis can be run on an version of java files, but have not been able to figure this out.
Ideally, I would be able to run gradle sonarqube with the Java 11 JDK. I found another question seeming to have success with Java 11 using Maven, but their error is different, and I don't think their solution would apply to me.
Is this problem solvable, or will I need to wait for Sonar Scanner to have support for JDK 11?
If someone like me this will helpful.
Source code Java 8(55), with jenkins and sonarqube scanner.
My error was
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
.....
java.lang.IllegalArgumentException: Unsupported class file major version 55
Check this link : Why does sonar-scanner force the usage of the embedded JRE?
And Change your sonnar-scanner.bat or sonnar-scanner.sh
use_embedded_jre=false

Can sonar build java 6 and java 7 projects on a single server?

We have a server that runs Sonar and previously only had Java 6 installed and everything worked fine. We now have a Java 7 project and are encountering the "Unsupported major.minor version 51.0" version when the Maven surefire plugin tries to analyze the project.
Is there a way to specify the Java version sonar should use for a specific project?
Java 7 is already installed on the server.
Thanks in advance!
Never mind found the JDK option under Advanced in the Jenkins configuration for the job.

Resources