开发者

How to add a class to a .jar library?

开发者 https://www.devze.com 2023-04-04 08:37 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号