开发者

Multiple packages in java project and jar files

开发者 https://www.devze.com 2023-02-27 07:00 出处:网络
I am trying to build java client for rabbitmq. I have my source folder as A.mq.client. Also I have a libs folder where I have my rabbitmq jar files. These jars have been added to build path. Everythin

I am trying to build java client for rabbitmq.

I have my source folder as A.mq.client.

Also I have a libs folder where I have my rabbitmq jar files. These jars have been added to build path. Everything works OK in Eclipse.

Then I export the entire project in eclipse as jar. jar contents are .classpath, libs folder and my package folder + rest of stuffs.

Now I am getting exception :

java.lang.ClassNotFoundException: com.rabbitmq.client.Consumer

com.rabbitmq.client.Consumer is in lib jars.

I am running jar using java -cp rabbit.jar A.mq.client.Worker where I want to invoke main method of worker class in my package and Worker is accessing jar pa开发者_Python百科ckages.


As far as I know, you can't generally package jar files inside of another jar file. Typically, you would have to expand all the various dependent jars prior to packaging up your final jar. If you've ever used Maven, this is what the maven-shade-plugin helps to automate.

See the answer in this question for more information.


The CLASSPATH lists places, where the classes are found - either in a directory or in a jar, but not

  • directories of directories
  • directories of jars
  • jars of directories
  • jars of jars
0

精彩评论

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