1

I have an executable jar(mainjar) with me, i have created it using a maven project. When i pass some argument to his jar, it will execute another jar(execjar) file which is placed inside the src/main/resource of mainjar. The problem is i am not able to access the execjar inside the mainjar. Here is my folder structure of mainjar

src/main/java
    MainClass
        code to execute execjar- 'java -jar execjar'
src/main/resource/
    execjar

The problem is when i package the mainjar using maven assembly plugin, i am not able to access the execjar inside the mainjar- nothing happens when i execute the mainjar.

Can anyone help ?

Parameswar
  • 1,951
  • 9
  • 34
  • 57
  • If you want to call java code from java code, you don't need to call `java` – Scary Wombat May 08 '14 at 08:18
  • ??? Why don't you instantiate the Main class of the execjar Manifest and execute it that way? – mwhs May 08 '14 at 08:20
  • yes, i understand , but the requirement is to create a utility(mainjar) hiding the details of the jar (execjar) which is being executed inside it – Parameswar May 08 '14 at 08:20
  • Runtime.getRuntime().exec("java -jar execjar")? – Andrew Vitkus May 08 '14 at 08:21
  • Have a look at [this post](http://stackoverflow.com/questions/12357136/reference-jars-inside-a-jar), apparently it's not possible. – Karolis.sh May 08 '14 at 08:25
  • i added the execjar to the build path, i am able to access its mainclass in the mainjar. But i am not able to package the mainjar , it says the class not found – Parameswar May 08 '14 at 08:37

1 Answers1

0

Look at the shade plugin to create an uberjar instead.

http://maven.apache.org/plugins/maven-shade-plugin/

Niels Bech Nielsen
  • 4,777
  • 1
  • 21
  • 44