Eclipse Error:Target runtime jre1.8.0_31 is not defined - java

enter image description here
I have imported one Maven project. During compilation of project I am facing some errors, which are described in image.
IDE version
Eclipse Java EE IDE for Web Developers.
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600

It seems your .class files are not generating. Try cleaning your workspace, then refresh maven dependencies in eclipse.
This will hopefully solve your problem, if your environment is properly set.

I had the same issue and to fix it I finally did a find/grep for the missing runtime name. This turned up .settings/org.eclipse.wst.common.project.facet.core.xml which contained a line <runtime name="jdk1.8.0_66">. I deleted that line and did a refresh on the module and everything was fine.

Got Project Build path and then select Targeted Runtime Select desire jre and apply the changes . After clean project everything worked fine for me.

Check the targeted runtime in the Properties of the project:

Related

"Package javax.xml.ws does not exist"

I am rusty on Java and completely new to IntelliJ IDEA, an IDE which has been causing a lot of problems for me so far.
I am trying to run a program with the line "import javax.xml.ws.Response;". However, I get the error message "package javax.xml.ws does not exist."
I've tried to select the "Add Java EE 6 JARs to module dependencies" automated solution by IntelliJ IDEA, but it doesn't seem to do anything.
(I believe I am running Java 11, if it makes any difference at all. According to the readme by the author of the code, I should be running Java 8, but so far I haven't been able to because I get an unrelated error when trying to change Java versions with IntelliJ.)
What do I do? Thanks in advance.
Your issue is not related to Java version. It will work for both version 8 and 11.
You will need to either download the jaxws-api jar or add it as a Maven dependency accordingly.
You may download the Jar from the below maven repository URL, and then add it to your build path, or update your pom.xml with this dependency:
https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api/2.3.1
This is intermittent issue and can eat up hours. Try to do below steps
Remove all dependencies from classpath.
Close the project and open it again.
Add all required dependencies.
Clean your project.
Go to Project Structure and change Project SDK to Java 1.8 solved my problem

JRE System Library is always unbound in Eclipse? (An internal error occurred during: "Launching Main". Model not available for helloWorld)

THE PROBLEM
I've been developing in Java for years, but a recent install of my tools on a new computer (Windows 10) has resulted in the strangest problem. When I create a new project, almost everything is underlined in red. The error reads Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor:
WHAT I TRIED:
A quick search online reveals that I should JRE System Library is most likely unbound, so I change it: Properties >> Java Build Path >> JRE System Library >> Edit:
All of the red lines go away, but I can't run my program. An Error reads:
An internal error occurred during: "Launching Main".
Model not available for helloWorld
On closer inspection, Eclipse shows an error in the src/test folder, but there are no files there.
When I restart Eclipse, all of the red lines reappear and I have to do everything all over again. It also cannot find the JUnit dependencies either, and I have to manually add JUnit 4 library to the build path.
DEETS YO:
OS Details:
Windows 10
Eclipse Details:
Version: 2019-09 R (4.13.0)
Java Details:
Java 13.0.1
Alright, so none of the posted suggestions worked but I independently found out what was wrong. In general, I've found that this solves a lot of weird Gradle activity, including the ominous "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.6-all.zip'" that a lot of people have problems with once they try to use Gradle with new versions of Eclipse.
Solution
When you install Eclipse, there's a Buildship Gradle Integration plug-in that is visible in the Eclipse Marketplace (it has a little graphic of an elephant next to it). When you get modern versions of JavaEE Eclipse, it comes with that installed.
The problem is that this isn't the most updated version of it.
So you have to click the button that reads "installed" and it'll update it. After you update it and restart Eclipse, your most recent version of Gradle will work.
When using gradle run this:
gradlew cleanEclipse eclipse
this will re-generate the eclipse project and this helped me
Under a fresh Eclipse, we encountered this "Model not available problem" on projects that do not use Gradle, but maven.
To update gradle did not change anything. We assume that there is a conflict between m2e and this plugin. We found 2 solutions :
A) Add gradle nature (even if unused)
Right-click on the project
Configure
Add Nature (elephant logo)
Run your app, enjoy
B) Uninstall gradle. (if not used and not mandatory for your eclipse version)
Help/Eclipse MarketPlace
Search "Gradle"
Go to "BuildShop Gradle Integration 3.0" (the elephant) which is indicated as installed and clic on the grayed installed button.
Uninstall it. It will restart eclipse.
Run your app, enjoy :)
In my case it is resolved by updating Buildship Gradle Integration 3.0 from Eclipse market place

Eclipse Oxygen - The project was not built since its build path is incomplete

I just installed Eclipse Oxygen and tried to open an existing project into the workbench but I get this error:
The project was not built since its build path is incomplete. Cannot
find the class file for java.lang.Object. Fix the build path then try
building this project
I tried right clicking on the project - went to Properties - Java Build Path - Libraries - Add Library - JRE System Library and selected Workbench default JRE (jre1.8.0_60).
I then cleaned and rebuilt the project but it then causes more errors to come up like:
ActionBar cannot be resolved to a type
Activity cannot be resolved to a variable
AdapterView cannot be resolved to a type
ArrayAdapter cannot be resolved to a type
Here is what made the error disappear for me:
Close eclipse, open up a terminal window and run:
$ mvn clean eclipse:clean eclipse:eclipse
Are you using Maven? If so,
Right-click on the project, Build Path and go to Configure Build Path
Click the libraries tab. If Maven dependencies are not in the list, you need to add it.
Close the dialog.
To add it:
Right-click on the project, Maven → Disable Maven Nature
Right-click on the project, Configure → Convert to Maven Project.
And then clean
Edit 1:
If that doesn't resolve the issue try right-clicking on your project and select properties. Select Java Build Path → Library tab. Look for a JVM. If it's not there, click to add Library and add the default JVM. If VM is there, click edit and select the default JVM. Hopefully, that works.
Edit 2:
You can also try going into the folder where you have all your projects and delete the .metadata for eclipse (be aware that you'll have to re-import all the projects afterwards! Also all the environment settings you've set would also have to be redone). After it was deleted just import the project again, and hopefully, it works.
In Eclipse, Right click Project -> Maven -> Update Project. It fixed errors in my project.
I'm also using Eclipse Oxygen, migrated from Mars. I faced the same error. I deleted .metadata, .recommenders folders and added projects from archive and issue is solved. I also use Android Studio but i like Eclipse much more.
At my system the Java Runtime JAR file jrt-fs.jar was not found because it was in the wrong directory. This file should be located in the "lib" subfolder. If you installed Java at "C:\Temp\java" the file should be here at C:\Temp\java\lib\jrt-fs.jar .
These are the steps to make jrt-fs.jar available to Eclipse:
Window / Preferences -> the "Preferences" Window opens
Select in the left menu: Java / Installed JREs
Press the [Add...] Button -> A window opens
Select "Standard VM" - The window "JRE Definition" opens.
Enter your path information:
JRE home = "C:\Temp\java"
JRE name = "MyJRE"
Select [Add External JARs...] to link the jrt-fs.jar
JRE system libaries: "C:\Temp\java\lib\jrt-fs.jar"
It worked for me with OpenJDK12 and Eclipse 2019-09 (4.13.0).
Eclipse reported me this error:
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project
I had faced this problem. I added the C:\Users\Office 2\android-sdks\platforms\android-19\android.jar to the Java Build Path's Library. And the project started to run again.
The problem occurred due to my carelessness. Yesterday night I was updating the Android SDK, and at the same time I tried to run the project, while the SDK Manager was uncompressing the system image. The Project couldn't start and the error occurred.
I tried all the methods given by others. But nothing worked. It solved when I added the android.jar to the library.
I guessed it that android library is missing. not the Java, when I saw the errors only at the android methods and imports. But when I read the posts, I got confused and wasted some time trying wrong way.
I had faced the same issue and tried different solutions, I have reinstalled my JDK 11 and restarted the machine, after that the issue gets resolved.
I got this out of the blue in a workspace that was working properly before. This problem seems to indicate that the project configuration somehow got corrupted.
Restarting Eclipse didn't help, but in the same vein as the answers dealing with Maven, regenerating the Eclipse project config with:
./gradle eclipse
or
./gradlew eclipse
if you use the wrapper, solved this problem for me.
I have similar issue when importing Spring Boot, jdk 11 (using
inside docker) project to Eclipse 2019 (2021), in Ubuntu, instead when
importing to Inteelij IDEA Community or NetBeans IDEs they do
not produce the same set of after-import errors as in Eclipse.
The Spring Boot is multimodule maven projects and two child
modules give such 2 "problems" in appropriate problems tab:
The project was not built since its build path is incomplete.
Cannot find the class file for java.lang.Object. Fix the build
path then try building this project
Next 2 errors are produced in two classes of aforementioned
maven modules:
The type java.lang.Object cannot be resolved. It is
indirectly referenced from required .class files
Manipulation with adding JDK 11 to submodules buildpath
just leads to the thousands of problems. Also it is
got when I use Eclipse-File-Maven-Update.
Moreover when I try to edit most of existing classes or add new ones
I got red underline that tells
Implicit super constructor Object() is undefined for default
constructor. Must define an explicit constructor
. So almost no opportunity to use Eclipse
even at prebuild stage as docker-compose should run build and
run. Indeed I noted that such issue is produced just when project
also uses modules (module-info files introduced in java9).
When I import project on jdk 8 (even not installed on
system), or even on jdk11 without module-info files all
is fine in Eclipse after import.
Another difference is that of when I use problem old no module
project the Build Path is composed with jre environment 8 and
maven dependency items, but when using
"module-info" project the Build path contains -module path,
and -classpath. So I even do not know where to add jre 11,
indeed adding does not resolve issue, just make more errors.
So what is the resolution of the case??? What settings to do
in Eclipse?

Cannot build jhipster project in eclipse

I cannot build a simple project (just created with yo jhipster) in Eclipse.
I'm getting the error:
Maven Dependency Problem
Missing artifact com.sun:tools:jar:1.6
Thare are other errors too but i think this is the one that is causing problems.
I can compile and run the same project from command line with mvn spring-boot:run
I googled for the error and found lots of solutions but unfortunately none worked.
If i check Eclipse configuration i can see that java.home points to C:\Program Files (x86)\Java\jre7 no matter what i do.
I tried to edit the eclipse.ini file adding -vm C:\Progra~1\Java\jdk1.7.0_51\bin\javaw.exe
I also double checked that my workspace and project are using a Jdk and not a Jre Vm.
Can someone please point me to the right direction please?
Thanks!
I had the same issue before... you are probably running your Eclipse with a JRE rather than a JDK. The sun tools jar is actually part of the latest JDK, and doesn't necessarily need to be inferred directly in your project.
See my comments, issue #1, in the attached link:
JHipster Eclipse project running out of memory in "main"
Try with STS and everything works. Seems to be an issue with your eclispe
I've imported the sample jhipster in Eclise (without STS) and everything was OK, after installing the maven dependencies.
To run the project, run as an application and search for the Application (com.mycompany.myapp.Application)

jar works in classpath not in targetplatform eclipse

I have a jar that is working fine in Eclipse in other peoples Eclipse environments here.
When I add it to mine, it does not get resolved but when I open target platform state, it is present there.
If I had add the jar to classpath as an external jar from the folder in the target platform, it resolves everything correctly and build is fine.
Does anyone have any idea what could be causing this? I've tried new target platform definition, new workspace, new Eclipse version etc... I don't think it is an issue with the jar as it is working for the other people in my team.
Eclipse info:
Version: 3.7.2
Build id: M20120208-0800
Anyone anything else I should try?
Moved to linux environment and issue disappeared using Eclipse 3.8.1.

Categories