2

I am wondering how I can self-extract a .jar file (and supporting files) then auto run the .jar file.

This would basically mean the application as a whole would run from the one click.

I have read and tried the 7zExtras but not had any luck so far. I get extraction failed Archive is corrupt.

Please note, this is not a self-extracting .jar file, but a .jar file inside a zipped folder that needs to be ran after extraction.

MrAnderson1992
  • 399
  • 1
  • 3
  • 11
  • have you looked through the following link http://stackoverflow.com/questions/27904532/how-do-i-make-a-self-extract-and-running-installer – scarecrow- Jun 20 '16 at 15:33
  • Its not the same but thanks anyway. The way I got it to work was by making the config file run a batch and the batch run the .jar file. Worked a treat although not pretty. I have read through the best answer on there and it didnt quite work as nicely but using the batch worked. – MrAnderson1992 Jun 20 '16 at 15:40

1 Answers1

0

If you have the jar (MyProject.jar) file inside a zip (MyZipDir.zip).

If you run the command below, it works fine:

Java -cp MyZipDir.zip -jar bin/MyProject.jar -- Assuming jar is in bin dir of zip file.

Once it works, you can create .bat or .sh as per your operating system as such:

MyRunner.bat

@ECHO ON
set CLASSPATH=.
set CLASSPATH=%CLASSPATH%;MyZipDir.zip
%JAVA_HOME%\bin\java -Xms128m -Xmx384m -jar bin/MyProject.jar
ragingasiancoder
  • 616
  • 6
  • 17
Neha Vari
  • 492
  • 3
  • 14