Error after reinstalling Eclipse and Java. Error in build path - java

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).

Related

Ubuntu: Unable to start eclipse

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".

How to deal with 'Incompatible Java Versions running 0' in Eclipse Window Builder?

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).

How do I set Java 7 in IBM Domino Designer

I have an agent in Designer and now I need to make it work. The problem I've encountered is a Java version.. In IDE I've used (IDEA) the Java version is 7 (I use it, cause coding in Eclipse is a nightmare). Now I've tried to put my code in Domino.. And got 30+ "errors", like can not catch multi exceptions, generics, "mismatch", etc.. Although I installed FP9(Fix pack) when I went Project -> Properties -> Java Compiler JDK is still 1.6. My domino version is 9.0.1 and I can not believe, that they didn't update Java since 2006. How can I set JDK and JRE to 7 (if not 8)?
You need to update your Designer to 9.0.1FP9 as that is the first version that uses a newer Java version (1.8). All previous versions use Java 1.6 (9.0.1FP8 started to implement Java 8, but not yet for Designer client).
Take care: All Clients and Servers need to be at least 9.0.1FP8 to be able to run your code.
AFAIK Java 8 in Designer is scheduled for FixPack 10, isn't it? And I don't expect that in the next couple of months...
But from 9.0.1FP8 onward it should be no problem to export a jar file from any IDE you want and attach it to a script lib (but beware of memory leaks)

Where is Java 8 hiding?

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.

How to change NetBeans Java Project Runtime?

How can I change the Projects Runtime Platform?
(standard NetBeans [8.1] Java Project [Java Application])
Details:
using Ubuntu with NetBeans 8.1
I have installed JDK 1.6, JDK 1.7 + JDK 1.8
My projects platform is Java 6.
My systems default Java is Java 7.
NetBeans-IDE was started with Java 8.
When I run the project via the IDE (Run project), the Project-Platform is used (which is Java 6).
I cannot change the Runtime Platform!
It's always: Project Platform
I tried to Manage Platforms..., but I still can't change the value of the Runtime Platform-ComboBox.
EDIT:
As I wrote in the comments, I don't want to change the Project-Platform.
The project should be compiled with Java 6 but run with Java 8 (when click on Run project).
What I want is:
Project-Platform = Java 6 (used to compile),
Runtime-Platform = Java 8 (used to run).
How can I change the Projects Runtime Platform?
Unfortunately you can't. As you point out, its value can only be Project Platform. Of course that invites the question "What is the point of even having that Runtime Platform field?".
I suspect that it may have been (unwisely) added to the GUI so that at some time in the future it will be possible to actually select a different JDK to run against. There is an open Bug Report for this: Bug 186747 - Can't Build and Run with Different Java Versions.
It's also worth noting that the Help documentation for the Run screen does not mention that Runtime Platform field. My own view is that the field should be removed until it serves a useful purpose.
What I want is: Project-Platform = Java 6 (used to compile),
Runtime-Platform = Java 8 (used to run).
Unfortunately that can't be done, as shown by the open bug. The best you can do right now is:
Create platforms for JDK 6 and JDK 8 in NetBeans.
Set the Java Platform to JDK 1.6 on the Libraries screen, and set the Source/Binary Format to JDK 6 on the Sources screen, then build to verify that no invalid APIs are being used.
Switch the Java Platform to 1.8 on the Libraries screen to run your 1.6 code under 1.8.
I realize that you don't want to do that, but unfortunately there's no silver bullet in the current release of NetBeans (8.2).
An alternative approach would be to build and run using only JDK 8, but include the Animal Sniffer Maven plugin "for checking projects against the signatures of an API", to verify that your 1.6 code was not using illegal APIs. But of course that's only viable for Maven projects.
Please look at Netbeans Project Setup - Setting the Target JDK in a Project
You just have to change the Runtime Platform at the Libraries option, that's all.
Just went through this pain for Apache NetBeans 14. I was trying to set a remote debug for a Raspberry Pi.
It works only if the jdk match on both the local and remote versions. In my case I set them both to 17.
I would have expected that the default jdk on the local machine should have been able to be changed but I fail to determine how.
I am running Ubuntu on the local machine so maybe the platform cannot be changed (don't know). Moving on.
Changed runtime platform

Categories