Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse not finding jar file(External jar file added to project, but imports from the jar file show errors)
Eclipse not finding jar file [message #1827788] Sat, 23 May 2020 19:25 Go to next message
Jim Anderson is currently offline Jim AndersonFriend
Messages: 103
Registered: October 2014
Senior Member
I have been away from Eclipse and java for a bit working on other projects so I am a bit rusty with Eclipse. I started a new project the other day using:

Eclipse IDE for Java Developers Version: 2020-03 (4.15.0) Build id: 20200313-1211

I have the following important statements in my java file:

import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.parser.ParseException;
import org.json.simple.parser.JSONParser;

The error for the first import statement above is:
The type org.json.simple.JSONObject is not accessible

In the project properties, I have added the external library:
json-simple-1.1.jar

and if I look at the project in the "Project Explorer" tab, it shows that the jar is included in the "Referenced Libraries" for the project, so I think the import statements should be error free.

Does anyone have an ideas on what I am doing wrong?

Jim A.
Re: Eclipse not finding jar file [message #1827798 is a reply to message #1827788] Sun, 24 May 2020 13:58 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1832
Registered: July 2009
Senior Member
Quote:
I have the following important statements in my java file:


important? :)

Quote:
The type org.json.simple.JSONObject is not accessible


Assuming that your project has a compliance of "9" or greater, this error message indicates, that the compiler finds the type, but the rules of the Java Platform Module System don't allow access to it.
Re: Eclipse not finding jar file [message #1835763 is a reply to message #1827798] Fri, 11 December 2020 19:08 Go to previous messageGo to next message
Jim Anderson is currently offline Jim AndersonFriend
Messages: 103
Registered: October 2014
Senior Member
I am installing Eclipse on another PC. Apparently, I managed to fix this problem some months ago, but I cannot figure out how.

@Stephan Herrman

In your response, you mentioned, "the Java Platform Module System don't allow access to it". I am not sure what you mean by the 'Java Platform Module System', but I assume you mean the module in Eclipse that compiles the java code. Assuming this, I'm wondering why the module would not be able to read the file. I have checked the jar file and it is readable on my file system. Are there rules in the 'Java Platform Module System' that apply here. If so, how do I find the rules?

Jim A.
Re: Eclipse not finding jar file [message #1835767 is a reply to message #1835763] Fri, 11 December 2020 20:18 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1832
Registered: July 2009
Senior Member
Quote:
I am not sure what you mean by the 'Java Platform Module System',


"Java Platform Module System" is the module system that has been introduced with version 9 of the Java Platform (d'uh). It's nothing that Eclipse invented.

Unfortunately, it's not trivial to give a simple, authoritative link for what it is and what it's rules are.

This one is official but quite a mouthful: http://cr.openjdk.java.net/~mr/jigsaw/spec/

Search the web for "Java Modules" and you'll easily come up with several introductions, tutorials and whatnot.

Mind you, that *all* software using Java 9 and greater has to adhere to these rules, even if not explicitly using modules. Such code simply resides in the "unnamed module".
Re: Eclipse not finding jar file [message #1835768 is a reply to message #1835767] Fri, 11 December 2020 20:45 Go to previous messageGo to next message
Jim Anderson is currently offline Jim AndersonFriend
Messages: 103
Registered: October 2014
Senior Member

@stephan herrman

Stephan,

Thank you for explanation and pointers. I will investigate.

Jim A.
Re: Eclipse not finding jar file [message #1835795 is a reply to message #1835768] Sun, 13 December 2020 13:46 Go to previous message
Jim Anderson is currently offline Jim AndersonFriend
Messages: 103
Registered: October 2014
Senior Member
For the record, I recompile all my code using Java 13 and everything compiled.

Thanks much to Stephan!!
Previous Topic:Cannot attach source code of an HttpServlet
Next Topic:2020-12 release
Goto Forum:
  


Current Time: Tue May 18 08:59:08 GMT 2021

Powered by FUDForum. Page generated in 0.01854 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top