I have "Eclipse IDE for Java Developers" (Version: 2022-06 (4.24.0)
) installed on my Windows 10 PC. I have a basic Hello World Java Project called test that runs fine, but when I open its Java Application
Run Configuration and click on the Source
tab, it lists the jar jrt-fs.jar
from the default JRE as being in the Source Lookup Path
49 times:
Screenshot of Eclipse Source Lookup Path for Run Configuration
Screenshot of test
project's Projects tab under Properties: Java Build Path
test
project's .classpath
file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Why is this listed so many times? I'm worried it will causes problems down the road.
Recently, I was working on a Java project in an Eclipse IDE, and through this post, I would like to discuss one of the errors that frequently occurs at runtime just because of an invalid JAR file. Especially after Googling and looking through StackOverflow with no definitive answer. I eventually figured it out and wanted to share the answer with the community so that no one else wasted time as I did (no need for everyone to reinvent the wheel).
The Issue Symptoms: You might encounter the following errors –
ClassNotFoundException
NoClassDefFoundError
java. lang. LinkageError: loader constraint violation
These errors are usually related to: Duplicate JARs in the build path, Multiple versions of the same library, and Conflicts in class definitions across JAR files.
Solution Steps:
Simply run the project and read what is logged into the console in Eclipse as follows:
Step 1: Find out what's wrong with this output. Run the above code simply & check with Console (Take care while reading). Look for errors like:
Exception in thread "main" java. lang. NoClassDefFoundError
Step 2: Open Build Path SettingsRight Click on Your Project → Build Path → Configure Build Path Go to the Libraries tab
So Step 3: Clear Duplicate / Conflicting JARs — Check for duplicates or different versions (Example):
selenium-java-4.1.2.jar
selenium-java-4.8.0.jar
Remove unwanted JAR → Keep the one you want (usually latest version)
Click Apply and Closese.
Step 4: Check file System (optional as helpful) Press Alt + F1 via your project lib/ or directory rootject (or external Folder directory are).
C:\Program Files\ Java
Get rid of unused or duplicate jar files
Step 5: Refresh your project Just Right click on Project in Eclipse → Click on Refresh Or Simply Press F5
This action makes Eclipse to reload the configuration as well as triggers a rebuild of the