how to use class files inside a jar file?

后端 未结 1 2007
你的背包
你的背包 2021-01-28 04:05

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 fil

相关标签:
1条回答
  • 2021-01-28 04:19

    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);
    
    0 讨论(0)
提交回复
热议问题