Reputation: 1267
I'm using eclipse, the jar files locate in ~/zmx/alg4/algs4.jar, the class file I need is algs4.jar/A.class. my project exists in ~/workspace/test. the jar file are already in Referenced Libraries, how can I use the class file in my project? I've already tried:
import A;
private A variable = new A();
but it doesn't work.
Upvotes: 0
Views: 400
Reputation: 1855
You can’t use classes in the default package from a named package: "[import] require a compile-time error on any attempt to import a type in an unnamed package". You may want to access it via reflection (see below), or repackage your library algs4.jar if you have the source code.
Class.forName("SomeClass").getMethod("someMethod").invoke(null);
Upvotes: 1