views:

108

answers:

3

Hey guys - I've looked through a plethora of forums online as well as asked many professional java developers but I was unable to find adequate assistance in creating a standalone runnable jar file of a financial application that I am currently finishing up. The application uses two external programs; an ImageMagick file conversion program called convert and an OCR program called gocr045. I developed this application via eclipse and have attempted numerous times to package the contents with eclipse's automated runnable jar file creation wizard. All works well on my machine and my app functions as it is supposed to, but for some reason whenever the app is run on a different computer it compiles and the GUI displays but the two external functions do not work. I have had these functions installed on the other machines but so far the only workaround that I have found to this issue is to manually create runnable jars on the machines via eclipse. This will unfortunately not work because the app is to be commercialized upon completion and I can't go around installing eclipse then installing the app for every user that buys it. I suspect it is some trivial issue and Java experts such as yourselves will hopefully be able to resolve it for me in no time. Does it possibly have something to do with signing the jar file?

Thanks and I hope to hear back from you soon,

Mark Kogan KoganApps (www.koganapps.com)

A: 

Have the seperate exes been added to the PATH on your machine? If you aren't specifiying the full path to the exe when you invoke the Runtime.exec() method you might be picking up the location from the system path.

I would

  1. Confirm exes located in known location relative to jar location
  2. Runtime.exec() method uses this known relative location
  3. Ensure exes are not held inside the jar (I don't think it will work if they are)

I don't think signing would have anything to do with it.

Michael Rutherfurd
A: 

Rafe-ultimately the goal is for the app to run on both Windows and Mac. I will use some sort of external software to convert the exe files on the mac to ones that will run on mac os x. Subsequently I will invoke the Runtime.exec() method on these converted files

Mike - I suspected that this was the case as I am not specifying a direct path to the external programs and the system path is probably being inferred when the jar is not running on my computer. The app consists of a JApplet wrapped in a JFrame, however; could the security restrictions on an applet have anything to do with the issues I'm having? And, of course, my exes are located outside the jar in an external folder from which they are invoked because the ClassLoader cannot run external programs in the same jar file where it is instantiated

Thanks for the help guys and I will get back to you shortly on my results - hopefully things work out now

Mark Kogan
A: 

As you have said there is a JApplet wrapped in a JFrame so it could be a security exception. Normally when you have a JDK installed on your system and you are using eclipse, it picks up the JRE inside the JDK folder. Once you bundle it as an runnable jar and try to execute it on a different system then there is a chance that it is picking up java.exe from c:\program files\java\jre\bin.. if this is the case then your app won't work, unless properly signed and given required access rights.

So, do the following check:

  1. which jre is being used on your system. whether it is inside jdk or c:\program files\java\jre\bin
  2. check the same on the other systems where you have deployed your app

Note: I have assumed that you have set all the necessary path variables.

Suggestion:

  1. In case you have access to the source code of the ImageMagick and JOCR then make a dll out of it and use JNA (https://jna.dev.java.net/) to call them.
  2. Use JPanel in place of JApplet
Favonius