How to add a class to a .jar library?
I need to add a class to a .jar library but I can't figure out how to do it.
I have a library named netty-3.1.5.GA.jar
but for some reason its missing a c开发者_如何转开发lass I need
(HttpTunnelClientChannelFactory.java
).
I have found that class on a repository but not as part of the library. So how can I 'inject' it? The class I need to add is using other classes that exist in the library.
You don't need to add it to the jar, you need to add it to the classpath of whatever it is you're running.
You can use the jar
tool to update the jar file: you will need to manually create the appropriate package directory though. Try this:
jar uf netty-3.1.5.GA.jar HttpTunnelClientChannelFactory.class
will add it to the root package. If you need it to be set up in a package directory you should create the directory structure and then add the file with a path.
EDIT: that should be .class
, not .java
.
精彩评论