I have been working on some class projects on a work computer with NetBeans 11 and uploading my progress to github. Recently, I came home and pulled my progress down to my laptop which still has netbeans 8. All of a sudden, when I try to run code, I get:
javac: invalid target release: 13
From browsing stackoverflow and other such forums, I gather that 13 refers to the version of the JDK. Apparently, there is some mismatch in my settings (either I am using an old version but NetBeans wants to use something newer, or maybe the other way around).
I went into project > properties > sources and saw a drop down bar titled "Source/Binary Format" with JDK 13 selected. I dropped it down to 9 (a completely random choice) and then tried to run my code again. Voila, it worked.
My questions are simply: What did I just do? Why did it work? Are there any implications for my program to be considered?
If you choose to answer please be aware that I know little about the inner workings of Java, and so a simple explanation is appreciated. I only know how to write the code, not what happens behind the scenes. I'm tempted to blindly plow forward with my coding, but I thought this might be a learning point. Perhaps not.
Basically, your IDE checks your code according to the rules of the language, and those those are different depending on language version because e.g. Java 7 has no lambdas but Java 8 does. Your project was configured to be checked against the rules for Java 13, but the older version of NetBeans wasn't able to do that, so you've asked for it to be checked against the rules for Java 9 instead. This will have no impact on your project unless you want to use features introduced in Java 10 or later.
The other purpose of this drop-down menu is if you want to compile your project so that it can be run using an older version of Java. If you're distributing a piece of software for users who still only have Java 8 installed, then you would want to limit the project to Java 8.
Related
This question already has answers here:
No JREs installed in the work space that are strictly compatible with this environment
(2 answers)
Closed 2 years ago.
I'll premise by saying I am new to Java
I'm trying to run a program in Eclipse. I really haven't done much at all in terms of building the program, I pretty much just added a GUI using JFrame by following a Youtube video.
My problem is that I'm getting this error whenever I try and run the program:
Description Resource Path Location Type
Build path specifies execution environment JavaSE-14. There are no JREs installed in the workspace that are strictly compatible with this environment. Calculator Build path JRE System Library Problem
I'm running SE-15. How should I fix this?
It appears that you installed the latest version, 2020-09, along with Java 15.
It's useful to know that Eclipse can run with a particular version of Java, even while your applications run in Eclipse with a different version of Java.
You have provided Java 15 to run Eclipse with, and that is what Eclipse assumes it will run applications with, by default.
However, at this point in time, the support in Eclipse for features that are new to Java 15 is experimental. There is an additional plugin you can install that will unlock the Java 15 features, although you probably don't need those yet.
Because the Java 15 features are disabled by default, it's using the execution environment of "JavaSE-14", but you don't have a Java distribution that is strictly compatible with that interface.
As a commenter pointed out, this is only a warning, so it's not likely actually causing a problem. You could likely get by ignoring this warning and focusing on the real errors in your application.
However, addressing the warning could be done in two different ways:
Install a distribution of Java 14, add it to the "Installed JREs" list, and edit the "Execution Environment" for Java 14 to refer to the Java 14 installation
Install the plugin that enables Java 15 features (I haven't done this), and ensure that the project uses the "JavaSE-15" execution environment (install the plugin from the "Marketplace Client", entering "Java 15" in the search field)
I tried everything I installed every possible Java file a million times I installed the newest gradle version but it continues to show this error. I'm on Mac. Please help thanks
IF you do not want to develop for Android Java 11 works fine libgdx.
You have to change some things before everything builds and runs.
Here's what I did to get my project working.
My context Mac OSX 10.14 and openJDK 11.0.2, new project, Desktop launcher and a bunch of Extensions (not important).
The error you get about not being able to find java 11.0.x comes from gradle. Java 11 is only supported since gradle 5. In order to use gradle 5 instead of 4.6 the generated project is configured with, go to <project-dir>/gradle/wrapper/gradle-wrapper.properties and change distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip into distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip.
That resolves the java 11 error just to confront you with a new error Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
To get rid of that, open <project-dir>/desktop/build.gradle and change line 27 (might be different for you)
from files(sourceSets.main.output.classesDir) into
from files(sourceSets.main.output.classesDirs)
thats classesDir into classesDirs
This should resolve all build errors and you're good to go.
I am strongly recommend to use Java version not greater than 8. It is many incompatibility issues I faced just on 9 version of JDK in Android Dev environment.
Uninstall all java you have, use this article, because it is not as such easy without knowledge: https://www.java.com/en/download/help/mac_uninstall_java.xml
After download the 8th version from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
I did same some time ago and all problems left
I have Eclipse installed with WindowsBuilder, and it has worked fine in the past in showing the design tab of JFrame.
I just installed Intellj, and installed a JDK in addition to my current SE-9 JVM. My eclipse program is still functional , but is showing the following when I open WindowsBuilder design:
Incompatible Java versions: Eclipse is running under 0, but this Java project has a
9 Java compliance level, so WindowBuilder will not be able to load classes from this
project. Use a lower level of Java for the project, or run Eclipse
using a newer Java version
There must be something to the zero, rather than 1.8 or 9.
Other StackExchange answers suggest that I downgrade my Java version, but when I went to project/properties/java compiler, it did not work.
My java compiler is linked to SE-9, so I am unsure why this new error is occurring. Maybe it is due to installing the JDK as well?
It's a known bug with the detection of Java version strings in Window Builder. Historically, the parsing of version strings was implemented to not check for the major version part at index position 0, e.g 9.0 or 10.0, but at index 2, namely 1.6, 1.7,...
Sadly, as of today, in the bug report 517291 we find this:
Patches welcome, we currently do not have active WB developers.
so somebody has to contribute a fix for this undesired behaviour that causes you pain.
So for now, you have to stay with Java versions less or equal to 1.8 if you want to use Window Builder in Eclipse. For reference, see this answer by greg-449 or this answer on this topic.
Hope this helps (for now).
This is probably a cliché question that was repeated a trillion times. But I'm asking here because I became fully and totally desperate and I need some pointers to continue.
I'm learning how to program games using LibGDX. I'm using this tutorial. The problem is the classic error:
Errors occurred during the build. Errors running builder 'Android
Package Builder' on project 'HelloWorld-android'.
com/android/dx/command/dexer/Main : Unsupported major.minor version
52.0
I understand that this error means that some how, Eclipse is using Java 8 to compile, and an earlier version of Java to run, which is creating this incompatibility. But guess what? I don't even have Java 8 on my computer! I have:
Android SDK
Java 7u79
Eclipse Luna
LibGDX, that generates the project for me.
I don't understand why this is happening, so please assist and tell me why this would happen. Following are screenshots of Eclipse showing that everything is 1.7.
And yet I keep getting this error on right click -> Debug As -> Android Application:
What did I miss? Where is Java 52 coming from?
I would like to point out that the Desktop version of the game runs with not a single problem.
Thank you for any efforts. Please don't hesitate in asking for more information.
It's not your code that requires Java 8.
"Error running builder 'Android Package Builder'
means something in the android build tools, some of which are also written in Java, require Java 8 to run.
You'll have to install Java 8 so that it runs Eclipse & gradle. Java 8 can compile for Java 7, so you don't have to change the project to Java 8 (which would also mean the app would only work with Android N and above).
The safest bet is to remove all Java < 8 versions from your computer, that way you can't accidentally run with an older version. You'll have to update the "installed JREs", set the default (& especially the one in the gradle screen) to your Java 8 install, but keep the project's "Compiler compliance level" at 1.7.
I am a relative newbie to programming, I have a bit of experience building Swing apps and I now want to try my hand at learning JavaFX. I am using Eclipse Kepler as my IDE.
I understood from the JavaFX website that JavaFX is included in the JDK7 - Quote: "The first step in getting started with JavaFX is to download and install the Java SE 7 JDK, which includes the JavaFX runtime libraries and utilities. See the JDK 7 and JRE 7 Installation Guide for instructions."
However, when I try to import the Oracle JavaFX HelloWorld example (http://docs.oracle.com/javafx/2/get_started/hello_world.htm) into an Eclipse project I get errors on the JavaFx package imports. The only suggestions I get are to create new classes etc or 'search repositories for javafx.application'
Does this mean that Eclipse does not support JavaFX out of the box?
So my question to the community is two-fold:
1. please explain how to use JavaFX working in Eclipse. I checked out other answers which seem to indicate that I should install f(x)eclipse. But...
before you tell me that this is a duplicate question, my second question is please also help me understand how, when Oracle say that JavaFX is included in JDK7, it is not possible to import those packages regardless of the IDE (just like it is possible with Swing).
Thanks
It is part of the JDK but not on a classpath hence extra work needed with Java7 - on Java8 it is on the ext-classpath - so the correct answer is - something being part of JDK does not mean it is on the classpath by default.
So tools like Eclipse need to take extra care of this.
Since JDK 7 update 51 JavaFX is a part of JDK: release notes