-1

I am building an app on mac osx using javafx maven plugin. This plugin automatically creates the complete JRE inside the Java.runtime folder during the build process. But it doesnt contain the java.exe inside it.

I want to launch a jar within the app but for that I need java executable also inside the app. If I paste the java executable from system java bin folder inside the Java runtime folder of my app , I am able to launch my jar (problem gets resolved) but I am not able to launch this app to the mac app store because the Java executable is code signed with Developer ID Application: Oracle America, Inc. and has a bundle identifier of net.java.openjdk.cmd .This doesnt allow my app to be uploaded on itunes.

Is there any way out , where using javafx maven plugin I also get the java executable inside my app during the build process rahter than copying it from my system java inside my app which has a different code signature.

ravthiru
  • 8,878
  • 2
  • 43
  • 52
yukzz
  • 59
  • 7

1 Answers1

1

Instead of trying to implement system-dependent code in Java, it is better to use the facilities that are available in Java for executing a jar in the current JRE. It is possible to create a URLClassLoader https://docs.oracle.com/javase/7/docs/api/java/net/URLClassLoader.html which links to your jar (and any dependencies). From there you can use reflection to load your main class from that classloader, and execute it. There is no need to launch a new JRE (At a huge cost in RAM) unless you need to make actual changes to operating system state, such as executing SUID.

See related question if you need to execute jars with privileged operations: Signed applet loads signed jar-files using URLClassLoader with security issue

Community
  • 1
  • 1
Ralph Ritoch
  • 3,260
  • 27
  • 37
  • Thank you .I am going to try to use URL class loader to load my jar .If this workaround works , I will post it for sure – yukzz Sep 16 '16 at 17:25