1

I have the "SomeJarA.jar" with the followiung structure:

SomeJarA
|
|--lib/SomeJarB.jar
|--com/.../SomeClass.class

Im trying to execute the "SomeJarB.jar" in "SomeClass.java" using:

Runtime.getRuntime().exec("java -jar SomeJarB.jar");

Is this possible?

kulmino
  • 55
  • 1
  • 8

2 Answers2

0

As far as I know, if there's a way to achieve this, it is going to be a tricky and highly unsupported arrangement. I'll look around for some supporting documentation, but I'm inclined to say "No."

This related link might help, though.

EDIT: Found the reference I wanted. It's here. Specifically, there's a note which says, "The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols."

Community
  • 1
  • 1
unigeek
  • 2,656
  • 27
  • 27
0

This is from user @Tezar and Question Classpath including JAR within a JAR

You can use "Class-Path" in your manifest file.

For example:

Create manifest file MANIFEST.MF

    Manifest-Version: 1.0
    Created-By: Bundle
    Class-Path: ./custom_lib.jar
    Main-Class: YourMainClass

Compile all your classes and run
jar cfm Testing.jar MANIFEST.MF *.class custom_lib.jar

c stands for create archive f indicates that you want to specify file v
is for verbose input m means that we will pass custom manifest file

Be sure that you included lib in jar package. You should be able to run
jar in the normal way.

based on: http://www.ibm.com/developerworks/library/j-5things6/

See the linked Question. It seems like the sanest method for jars in jars and avoids third-party class loaders. If you feel like upvoting, go to Tezar's answer and upvote that entry, not this one, as this is just a copy.

Community
  • 1
  • 1
Brian Tiffin
  • 3,978
  • 1
  • 24
  • 34