java - How to reference a class in an external JAR in Eclipse? -
i reference class bag
in jar file, eclipse telling me bag cannot resolved type
. have added jar in bag
defined classpath project, error still there. doing wrong?
i think can't that, because handbag class in algs4.jar within default package. before j2se 1.4, still can import classes default bundle using syntax this:
import unfinished;
but j2se 1.5, that's no longer allowed. if want access default bundle class within packaged class requires moving default bundle class bundle of own. read here more detail explanation :
how access java-classes in default-package?
some options can take :
access class via reflection or other indirect method. little bit hard, :
class fooclass = class.forname("foobar"); method foomethod = fooclass.getmethod("foomethod", new class[] { string.class });
string fooreturned = foomethod.invoke(fooclass.newinstance(), new string("i did it"));
if own source code of jar library, need set in bundle , wrap 1 time again new jar library.
java eclipse
No comments:
Post a Comment