Is there a java10 compatiable version of the javafx gradle plugin? - java

I need to run a java application in my gradle build. That application uses reflection, and will not run in java 11. So my gradle JVM needs to be java 10. (A dead end, I know, that's what I'm working on)
But my build configurations currently use the javafx plugin, and all the versions on plugins.gradle.org are built with Java 11 classes, so the plugin won't work with Java 10.
I compiled the javafx plugin for Java 10 with sources from github, but the plugin is configured to use java 11 repositories, so I'd need to figure that out and replace them.
It would save me enormous hassle if there was already a javafx plugin that works with Java 10.

Related

How do I successfully change the Java version in a Spring Boot project?

I recently started a new Spring Boot Gradle project, using IntelliJ. When making the project, I chose Java 17 as the project Java version. My build.gradle file had sourceCompatibility = '17', but my JAVA_HOME environment variable is set to Java 11 and I don't really want to use Java 17.
I tried changing sourceCompatibility to 11, and went into
File -> Project Structure -> Project Settings -> Project
to change the SDK to 11 as well.
Whenever I click the "run" button in IntelliJ, as well as when I try to build my project in command line with ./gradlew clean build, I get a bunch of errors, mostly complaining about compatibility issues. They all read almost the same; here is the beginning of the errors from the failed build:
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1-SNAPSHOT.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1-SNAPSHOT:20221222.181044-39
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1-SNAPSHOT:20221222.181044-39 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1-SNAPSHOT declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
- Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1-SNAPSHOT declares a runtime of a component, and its dependencies declared externally:
I don't want to have to start my project over just to fix this compatibility issue. I'd prefer not to have to switch between Java versions (I know about jEnv, just prefer to leave everything on my computer set to Java 11 for now). Is there a way to fix this project without trashing it and redoing it?
IntelliJ IDEA > Preferences > Build, Execution, Deployment > Gradle > Gradle JVM -> java 11 photo
x
Java 17 required
Spring Boot 3 requires Java 17 or later.
See the Spring Blog page, Preparing for Spring Boot 3.0. To quote:
Spring Boot 3.0 will require Java 17
Also note that Spring Boot 3 is a major update, with changes that break backward compatibility. Amongst these changes is the change in package names from javax.* to jakarta.*.
You said:
I don't really want to use Java 17
I cannot imagine why you would choose Java 11 over Java 17.
Most any Java app or library that runs on Java 11 should run on Java 17. I do not recall any problematic changes like there were between Java 8 to 9 to 11.
Both Java 11 and Java 17 are long-term support (LTS) versions.
Spring 3 requires Java 17 Spring Doc. You can downgrade Springboot version (org.springframework.boot) in build.gradle file, if you want to work with Java 11
To change your java version for the project:
Have to set the java path to the environment variable path with JAVA_HOME and also do the same changes in the path.
just delete the .gradle and .idea folders in your project and restart the project with the same IDE.
Important thing you have to change the source compatibility with your new java version and do the same changes in the project structure and configure the same JDK version.
The accepted answer does not work for me. Even after setting the Gradle JVM and restarting the IDE several times, it did not work. The only solution that worked is to change the JAVA_HOME to point to the directory of your preferred Java version and then restart IntelliJ.

How to run old version of gradle?

So I am trying to learn how to code minecraft mods for 1.8.9. This is an old version and I was told to use Java 8 to code it. I tried to run Java 8 with Eclipse but from what I am seeing, it only uses version 11+.
Is there a way to maybe download an old version of eclipse that will run 1.8.9 gradle?
The current Eclipse can run code using any version of Java. Eclipse itself needs at least Java 11 to run, many Eclipse downloads include a suitable Java.
Once you have installed Eclipse you can tell it about other versions of Java which can be used to run programs. Open the Preferences and on the "Java > Installed JREs" page add the JRE/JDK you want to use. You can specify as many versions as you like here.
You can then choose the Java to use in the project Properties and in the Run Configuration.

What version of Java should I use for developing my MOJO Maven Plugin?

I am currently implementing a new Maven Plugin and I would like to use Java 11 for compilation and execution.
However, I would like my Maven plugin to be used by most of our projects. Some of them are running in Java 8, some in Java 11.
Is it mandatory to use Java 8 in my Maven Plugin if I want it to be included in other project ? Is there a way to implement it in Java 11 and make it available for Java 8 project ?
As quite often: it depends. And with Maven Java is used at different levels, so this requires a bit of explanation:
Are you going to use Java 9+ specific features/APIs?
If not, you can build your project with Java 11, but you need to add <release>8</release> to the maven-compiler-plugin to ensure the code is Java 8 compatible.
If you do plan to use Java 9+ features/APIs, add <release>11</release> to the maven-compiler-plugin. Now you require your users that they run Maven with at least Java 11 (which is not a problem, even Maven 3.0 runs fine with Java 14-ea).
Even though Maven runs on Java 11, your users can still create Java 8 compatible projects (just like the "if not, ..." from the first bullet), but most are used to run and build with Java 8.

Cannot compile Maven project against Java 6 when using AspectJ plugin

I recently upgraded to Maven 3.5 and Java 8 on my dev environment as I have upgraded my company's Maven-managed application from Java 6 to Java 8 on our 'master' environment. Unfortunately I have run into difficulty using this setup against older versions of the application that are set to compile against Java 6, as Maven tries to compile against the version of Java it is currently running against (in my case Java 8). I have looked into using Maven Toolchains (details here), but this won't work because a couple of our Maven plugins are not 'toolchain aware', such as the AspectJ Maven plugin, which therefore tries to compile the project against Java 8 and thus I get compile errors. I think I will have to resort to running two Maven installations side-by-side and just switch between the two. But before I do that, does anybody know of any potential solution to such a problem?
Thanks in advance

How to execute gradle plugin with different version of java

I am running into an issue with my gradle build script, build.gradle, for my java project. In this script I need to compile the application with Java 6 in order to comply with the application specifications. However, I am also using a gradle plugin that performs code analysis that needs to be run under a Java 8 JVM. What do I need to do in build.gradle or other gradle settings in order to get this plugin to use a separate Java JVM?
I need to do something like this as gradle tasks fail because the plugin is reporting a Unsupported major.minor version 52.0 Error.
Research
I have done some invesitigation and I did see the following mentioned:
options.fork = true
options.forkOptions.executable = System.getenv('OTHER_JAVA')
Where OTHER_JAVA is an environment variable to the other version of Java. However, I have not been able to get this to work for the plug-in and after some more research, it looks like this may be more limited to compiling with a separate version of java, not executing.
See: How do I tell Gradle to use specific JDK version?
You've pretty much answered your question yourself:
it looks like this may be more limited to compiling with a separate version of java, not executing
Run Gradle under the Java 8 (that would mean specifying your JAVA_HOME as JDK 8), and fork the compiler for your app with Java 6 (as per your research).

Categories