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.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.