Related
Component Details - Using IntelliJ IDEA 2017.1 CE and jdk-9-ea+154
main() -
Set<String> set2 = Set.of("a", "b", "c");
set2.forEach(System.out::println);
module-info.java
module collection {
requires java.base;
}
Logs -
Error occurred during initialization of VM
java.lang.RuntimeException: Package jdk.internal.jimage.decompressor in both module jrt.fs and module java.base
at jdk.internal.module.ModuleBootstrap.fail(java.base#9-ea/ModuleBootstrap.java:699)
at jdk.internal.module.ModuleBootstrap.boot(java.base#9-ea/ModuleBootstrap.java:329)
at java.lang.System.initPhase2(java.base#9-ea/System.java:1928)
Doubtful over the implementation of initialization of VM, my question is that I haven't included module jrt.fs - Where is it coming in the picture from? How do I debug such modules inclusion/exclusion? How do I further solve the current exception?
I got the same error under Arch Linux. The package java-openjfx installs its libraries into the lib directory of the openjdk, which seems to cause problems.
I found a workaround by adding not the whole lib directory but only the needed libraries instead.
In project structure > Libraries > + > Java > /usr/lib/jvm/default/lib > select needed libraries (holding ctrl)
should look something like this
Then in Run Configurations set the VM Options accordingly
--module-path /usr/lib/jvm/java-14-openjdk/lib/javafx.base.jar:/usr/lib/jvm/java-14-openjdk/lib/javafx.controls.jar:/usr/lib/jvm/java-14-openjdk/lib/javafx.graphics.jar --add-modules=javafx.controls
For my project it was enough to only add controls as module but the path to base and graphics were required to get it to run.
I had the same issue on Manjaro Linux, while it was working fine on windows. Looking at the differences it became clear that the javafx 11 package installs into /lib/jvm/java-11-openjdk/lib, which I then set as PATH_TO_FX. This seems to be the issue, because jrt-fs.jar is in the same folder.
I moved all files from fx to a separate folder and then set that as PATH_TO_FX. Now it works fine.
$JAVA_HOME/lib/jrt-fs.jar contains a copy of the "jrt" file system provider compiled to JDK 8. It's for tools such as IDEs that run on JDK 8 but need to access a JDK 9 run-time image.
From the exception then it does appear that this JAR file, or maybe $JAVA_HOME/lib, has been put on the module path in error. JAR files that do no contain a module-info.class in the top-level directory are treated as automatic modules so this is why the exception has "module jrt.fs" in the message. The exception basically just means that you've ended up with two modules containing the jdk.internal.jimage.decompressor package (and many other packages) due to putting jrt-fs.jar on the module path.
To fix this problem, please follow the below steps.
1- Right-click on your class.
2 - Run AS-> Run Configurations
3. Click on main ->
Click on the Browse option and Choose your project name in project.
Click on the Apply button and after processing click on the Run button.
Try to remove jrt-fs.jar from the directory of jdk9. I did it in Project Structure in IntelliJ IDEA and it works fine for me
In Eclipse, changing the Eclipse workspace or deleting the .metadata folder in the workspace folder worked for me.
I don’t know what fixed it, but if I had to guess it could be something in the .metadata folder that caused the exception.
I faced this issue for Spring Toolsuite 4, The metadata contains info about the present projects in the workspace, and common eclipse settings like font, codestyle, run configurations settings and sometimes information about modules used, eclipse plugins & eclipse log file for eclipse log errors, etc.
It does not contain valuable project info.
If this folder is deleted or changed manually, eclipse sees this directory as a new fresh workspace. You have to import the existing projects again and you are done.
If you want to keep your fonts, codestyle etc you can export / import these preferences for new workspaces or create a backup of .metadata.
In my case it worked for above issue of Package jdk.internal.jimage.decompressor in module jrt.fs and module java.base when i deleted .metadata folder, import project again, setup run configuration and everything started working.
remove the .metadata folder, then restart eclipse.
I had the same issue on a Mac Eclipse Version: 2020-09 (4.17.0)
Whenever I tried to run my existing Configuration I got that error.
I tried all kinds of workarounds but nothing worked.
So I created a new Configuration:
Open file containing main() method.
From Run menu select "Run As >> Java Application"
That ran OK. The advantage of this is that it does not modify your JDK installation.
Removing the .metadata folder in the workspace folder works for me.
(I'm using Windows with Eclipse 2021-06 (4.20.0))
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?
I have several Android projects in Eclipse, and all is fine, except one (a library) that can not resolve any imports.
The java.io imports do resolve fine in other Android projects in the same workspace, and previously (I haven't used it for over a year) this library worked fine, too.
Any ideas?
Check two things
Eclipse preferences
Check your Eclipse preferences: Java -> Installed JREs
The one that you're using should be marked and it should be a JDK not just a JRE.
Project build path
Also check your project's build path: Right click on the project -> Properties -> Java Build Path
Check in the libraries folder whether the JRE System Library is present and ...
If not add it using Add library -> JRE System Library and then
select the correct one (from an installed JDK).
I am using Maven an this is what I did to re-solve -->
Right click on project
Maven -> Update Project. Make sure you choose 'Force update of Snapshots/Releases'.
Also check the 'clean project', 'update project conf from pom' and 'refresh workspace resource options' and click ok.
The following worked for me:
Close the project and reopen it.
OR
Clean the project ( = rebuilds the buildpath and thereby reconfigures the JDK libraries).
I was missing the JRE Systems Library in my Project Tree.
And navigating to Projects' Build Path and 'Add(ing) Library' worked!
I just ran into this problem with Eclipse 2022-6 and java-17-openjdk-amd64. I just appeared during editing in another file, the same code had worked before.
For me, all settings were correct and none of the above tricks worked. What I then did was completely removing the import command import java.io.Closeable;, saving the file, adding the same import command back at the same place, and saving again. The error disappeared.
When I installed the latest installment in Mac OSX - the Mountain Lion - I experienced some problems getting Eclipse to work I also lost most of my Android developer files (but I still have my projects). I suspect this is due to the choice of removing the /Developer and move the XCode and other Apple developer tools (I placed my Android tools here).
I have now installed the latest version of Eclipse and the problem still seems to be around. There are errors in all my projects and I get an error message prompting:
The type java.lang.Object cannot be resolved. It is indirectly referenced
from required .class files
I tried to check the Java class-path both in Eclipse and in my terminal and these seems to be OK. java and javac both run in my terminal and there is a valid path to the java source files in Eclipse (Under Preferences, Java, Installed JREs). That being said I'm not an expert in Eclipse so there may be that I have misunderstood how this problem ought to be solved. Anyone here with similar problems or who know the cure?
Make sure that you have a valid JRE or JDK defined in the Java Build Path of your project. Right-click on your project, select Properties... and then Java Build Path.
I had this problem moving a Maven project from Eclipse to RAD. I had a JSP file that worked in Tomcat and JBoss, but threw a NullPointerException in WebSphere on the form definition during the compile.
Anyway, after transforming the Maven project into an Ant project (mvn ant:ant), I imported the Ant project into RAD and got this error. The fix:
Open the Java Build Path, selecting the Libraries tab.
Find the JRE System Library and remove it.
Add the JRE System Library.
Goofy, but it works. It must reset some property in a file. I don't know if the problem is the older version of Eclipse or RAD.
After updating my Android SDK to make Appcelerator Titanium happy, I started getting "java.lang.Object cannot be resolved" for my Android projects in (non-Titanium) Eclipse.
I updated all dependencies in Eclipse, and the error healed after a restart of Eclipse.
I had that error almost every time I launched Eclipse for the first time; if I close and then re-open Eclipse, the error is gone.
I found this solution useful, though (I've copied here to protect the link, credit goes to the original author):
In Eclipse go to Windows -> Preferences -> Java -> Installed JREs.
Select the currently active JRE/JDK and press the Edit button.
Select the rt.jar and change its position in the list of JRE system libraries (e.g. press the Up button once).
Confirm all changes, clean and rebuild the workspace.
The next time you face the problem reposition the rt.jar again (or reset the order by pressing the Restore Default button).
please select your installed system jre version from java build path.
Try the following and problem will go away
Close the project and reopen it.
Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries)
OR
Delete and Re-import the project and if necessary do the above steps again.
This is an annoying Eclipse Bug which seems to bite now and then. See http://dev-answers.blogspot.de/2009/06/eclipse-build-errors-javalangobject.html for a possible solution, otherwise try the following;
Close the project and reopen it.
Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries)
OR
Delete and Re-import the project and if necessary do the above steps again.
The better cure is to try NetBeans instead of Eclipse
I got this error and what I had to do was remove the JRE from the Window/Preferences/Java/Installed JREs and re-add it. This somehow cleared up eclipse's cache and rebuilt the project successfully. To get rid of the error in the file-editor I also had to close it and open the file once again.
My problem was that I had in Eclipse: Window / Preferences... and then in the tree on the left Java / Installed JREs: C:\Program Files\Java\jre7
I changed to: c:\Program Files (x86)\Java\jre7
It solved my problem.
I had the same issue and none of the above solutions worked for me.
Then I realized than the library (libs) folder was missing in the project. Once i added the libs folder and the corresponding Jar file, the issue was resolved..
If your project specific (or if not applicable, workspace default) JDK/JRE is being referenced correctly and you've just begun to get this issue out of the blue: restart Eclipse.
Unfortunately, "restart Eclipse" is one of the standard troubleshooting steps when a project won't build. Eclipse even has a dedicated entry under the File menu.
I had to add the JDK under the build path. After adding the correct build path it worked.
I just had to restart eclipse, and the error went away. Strange.
I solved this by pointing my eclipse to the jre available in jdk.
This error caused by invalid sdk is pointing in your project.properties file of your project.
project.properties -> target=android-19 . change to version which is installed in your eclipse.The error will be gone.
I had the same issue after moving from JRE7 to JDK7. Finally I had to remove the JRE7 configuration from the Eclipse preferences and then add the following two lines to the eclipse.ini file.
-vm
C:\Program Files\Java\jdk1.7.0_55\bin\javaw.exe
I had this problem, and I understood that Eclipse has automatically imported a core reference, instead of the reference for the project I needed.
Deleted the import, and rearranged it, and everything worked fine.
Same problem facing Me
Project->properties->Android
And select the api level and also go in java build path and check some external jar file path if we already add in it.update the jar file path
On "The type java.lang.Object cannot be resolved. It is indirectly referenced
from required .class files":
I found my project had 2 meta-inf.java files in 2 different directories with the same 'module ' on line one (a copy/paste error).
Once this was corrected, I cleared the meta-inf.java file with the issue, rebuilding it line by line, guided by Eclipse, until I had a working module configuration.
I'm trying to get an app to compile that uses the android-support-v4.jar and the Fragmentation classes it contains, but I keep getting messages whenever I try to compile that there are errors in the code. All of the errors have to do with different Fragmentation classes that are in the .JAR. I have tried ctrl-clicking the project folder and then selecting Android Tools -> Add Compatibility Library and I keep getting this error:
[2011-12-20 11:55:31 - Android Compatibility JAR not found:]
/Applications/eclipse/Eclipse.app/Contents/MacOS/v4/android-support-v4.jar
Why would it be looking for the .JAR in Eclipse's Package Contents? I've gone into the project properties and went to the Java Build Path, and imported the .JAR from the MainActivity/libs folder, that didn't work, and then I tried to import it from my SDK directory, and that didn't work. I've fixed the project properties and cleaned and built it countless times, I've restarted Eclipse, my computer, re-downloaded and installed Eclipse, the Android SDK's and ADT and still nothing. I am completely stumped.
Edit
I've gone through the build path and imported the .JAR from both the MainActivity/libs and my SDK directory. For the hell of it I added the .JAR in the directory that keeps appearing in the errors and that hasn't worked. What's making Eclipse look for it in it's Application Package Contents?
Update
So after tinkering the project contents aren't showing any errors but the MainActivity folder still says that there is one and I still can't compile.
Like nyah:
Revision
So I think the question may be "Why is Eclipse looking for the .JAR in the Eclipse Application's package contents instead of the libs directory of the project or the Android SDK directory that I used to import it as an external .JAR?"
Update #2
I am only getting one error now after tinkering, it's on this method:
#Override
public MenuItem setOnActionExpandListener(OnActionExpandListener onActionExpandListener) {
// Noop
return this;
}
The Quick Fix says that I should delete the #Override annotation but that method must override a super class method.
These are the errors that it shows:
Multiple markers at this line
- The method setOnActionExpandListener(MenuItem.OnActionExpandListener) of type SimpleMenuItem must override a superclass method
- implements android.view.MenuItem.setOnActionExpandListener
Looks like it is looking for jar here :/Applications/eclipse/Eclipse.app/Contents/MacOS/v4/android-support-v4.jar
android-support-v4.jar is found in <sdk>/extras/android/compatibility/v4
Please make sure you add this as an external jar in the java build path
I could solve this problem by
1- delete "android-support-v4.jar" from lib
2- right click on the name of the project choose "Android Tools" and "Add Support Library"
If this is still not solved:
Like already said, in Eclipse go to your Project Properties > Java Build Path > Libs > Add External and get the one from the adk directory.
Also set up Java 1.6 as your default compile version if you already haven't. This should solve the Override Errors you described.
It turns out that my Debug Certificate had expired so I just needed to delete ~/.android/debug.keystore and restart Eclipse and everything worked.
I realize that this question has been answered, but this is a known issue that is supposed to be fixed in the ADT-17 plugin release according to comment 9 here: http://code.google.com/p/android/issues/detail?id=21488
In addition, people who have this problem can copy the compatibility JAR to the location it says it can't find it. Clearly it's looking in the wrong place (since it's checking the Eclipse directory rather than the android-sdk directory), so the simple fix, for now, is simply to put the package where it wants to find it, even though it doesn't belong.
For me it was as simple as copying the v4 directory within C:/android-sdk/extras/android/support/ into the C:/eclipse/ directory.
I had the same problem running in Ubuntu. Go to Tools->Options.
Check Force https://... to http://
Open Android SDK Manager. Check Extras->Android Support Library.
Something similar happened to me. At the top of MainActivity.java I had the next imports giving errors:
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
In each of the lines on the left they had the light bulb making some suggestions. If you click on it, one of the options will be "Fix project setup". You then will be able to choose between several options for fixing the imports, you should choose the one that specifies the android-support-v4.jar.
Right click on ur project --> select android tools --> select add support library and simply installed the supporting libraries.
Do you try not to do Android Tools -> Add Compatibility Library, and only add the jar in java build path library?.
I use this jar library of this way and it works without any problem.
I had the same problem.
Under the project properties:Java Build Path:Order and Export tab, the box next to android-support-v4.jar wasn't checked. I checked the box, and the error went away.
Another caveat was running Android SDK Manager in Windows 7 without administrator privileges. It would try to install support package, but would always fail, and the actual package never got downloaded to
C:\Program Files (x86)\Android\android-sdk\extras\android\support\v4\android-support-v4.jar
Solution: Make sure that you enter the same API for "Target SDK" and "Compile with" during Android project creation (or in the Manifest file once created).