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.
Related
I removed java-11 and installed jdk-1.8. Now when I try to start eclipse then its throwing the following error:
Being a beginner I searched and found some solutions but not worked for me
Ok. I'm going to make some assumptions based on some implications of what you've said here.
I assume that you had Java 11 installed, and you had installed Eclipse, and it was working.
You then, for some reason that I can't understand, decided to uninstall Java 11 and replace it with Java 8.
The error message is because when you had Java 11 installed and you installed Eclipse, Eclipse stored the path to the Java 11 distribution in the "eclipse.ini" file. Now that Java 11 is gone, it cannot start up.
The easiest way to fix this is to reinstall Java 11, and hopefully it will install into the same location as that error message shows it is looking for it.
Now, to address why you might have thought to replace Java 11 with Java 8. I'm guessing you're working on an application that requires Java 8 to compile and run. In this context, it's somewhat understandable that you would have done what you did, but it was the wrong thing to do.
Eclipse can run with one Java version, but build and run applications with a different Java version. In fact, I think it's generally a good idea to run Eclipse with the newest version of Java it can run (generally about a version short of the latest), but build your applications with the version of Java required for those applications.
So, you should have both Java 11 (or newer) AND Java 8 installed. Run Eclipse with Java 11, and build and run your applications with Java 8. In Eclipse, you have to register the Java 8 distribution in "Installed JREs" in Eclipse preferences, and also record that Java distribution in the "JavaSE-1.8" Execution Environment, in the preferences tab right below "Installed JREs". Set your application to require "JavaSE-1.8".
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.
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'm somewhat new to Java. I'm getting the error below when trying to build my project.
Errors occurred during the build.
Errors running builder 'Java Builder' on project 'spring-data-marklogic'.
Version '9' not supported
From what I can tell it wants me to use Java 8. I've went into Eclipse (Spring Tool Suite) preferences and changed the JRE and JDK to be 8.
I've edited JAVA_HOME to also point to version 8.
However, 'java -version' tells me that I'm still using 9. Regardless, I would think that at least changing the Preferences in my IDE would fix it.
This makes me believe that maybe it's a different issue all together. Any help would be appreciated!
I have been programming in Eclipse for a coupe of weeks. I had to remove Eclipse and Java for software update. However after I reinstalled Eclipse (Indigo) and Java Jdk (Java SE 8 (MacOS X Default)) I started to get errors.
The printer, scanner and object oriented programming method works fine but the Swing Components throw errors. Everytime I use method such as this.add(confirmButton); I get errors. The Error is :
The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from required .class files.
The internet suggested to fix the Build Path but I am only allowed to Use the default Java SE 8 because other execution environment gives an error
No JREs in workspace compatible with specified execution environment: JavaSE-1.7.
Not entirely sure if this is the problem, but as far as I know, Eclipse Indigo is way to old -- four year by now! It was outdated even before Java 8 arrived and never got support (like Kepler got, via a patch) for the new language features, such as default methods on interfaces and the like.
If you want to use Java 8, you should use a newer version of Eclipse. The current version that will properly work with Java 8 is Eclipse Luna (4.4).