1

I'd like to use a jar file in a project.

I do, what always: build path, libraries, add external jar...

The jar appears in Eclipse on the left side under JRE System Library...

In the jar file there is a class with static methods (the class has a private constructor).

I would like to call a static method, but Eclipse can't see the class and none of them...

Strangely, if I do the same with another older project, then Eclipse can see the classes (you get recommendation with ctrl space).

I changed from 1.7 to 1.8 for a while, but I don't think that it matters, cause the one older project I updated to 1.8 the other not.

I can't see the classes in the jar in the new projects...

Any ideas? Thanks!

user3435407
  • 1,019
  • 4
  • 15
  • 31
  • That's eclipse .Try to Add your classes into a package("name it") inside the project,if again you can't access add the external jar to an extra library("name it") . Madness like these are working for me(sometimes) – crAlexander Feb 15 '15 at 23:57
  • doesn't seem to solve this one... :/ Now I tried: extract the jar file, copy the .java files into a project.. but there are imports in the classes that would need other stuff, that I don't have. I don't even know whether I could have solved it that way, I am not that experienced... – user3435407 Feb 16 '15 at 00:25
  • tell me (for example you have your class lets say it MyClass) you cant import the classes from jar file into MyClass? and also you have done exit and reopen eclipse(and a refresh) – crAlexander Feb 16 '15 at 00:30
  • Yes, I have lets say MyClass in MyProject. I just right click on MyProject -> Bulid Path -> Add External Jar In the jar, there is a class StdRandom. API: http://algs4.cs.princeton.edu/code/index.php#stdlib (you need to scroll down a bit, the jar files name is: stdlib.jar) Now I should be able to simply use StdRandom in MyClass. And this works, with exactly the same steps, with older projects. But it doesn't in new projects... dunno – user3435407 Feb 16 '15 at 00:43
  • and yes I tried restart, i worked 3 years as a help desk agent :) – user3435407 Feb 16 '15 at 00:47
  • Thanks crAlex, the duplicate solved it indeed, I haven't found it though before! – user3435407 Feb 16 '15 at 01:04

0 Answers0