2

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)

Mark Kogan
  • 21
  • 2
  • What do you mean "includes exe" files? Do you use `Runtime.exe` to launch these programs? – Starkey Sep 13 '10 at 03:12
  • yes - i use the Runtime.getRuntime().exec(cmd) method for first the ImageMagick program then the gocr045 one – Mark Kogan Sep 13 '10 at 03:41
  • perhaps there is a file path issue but I don't see this being the case because the jar works on my machine and fails on other ones with the same exact file configuration – Mark Kogan Sep 13 '10 at 03:42
  • Are these other machines running Windows? More importantly, will your commercial users run windows? Because I don't believe this will work on platforms other than windows (.exe). You may have to work out a way to get these to run on the JVM so they can be part of the runnable JAR. – Rafe Kettler Sep 13 '10 at 03:47
  • This may be helpful to you: http://stackoverflow.com/questions/600146/run-exe-which-is-packaged-inside-jar – Rafe Kettler Sep 13 '10 at 03:49
  • Show the code calling your external program and the stack trace for when it fails. – Thorbjørn Ravn Andersen Sep 13 '10 at 04:09

3 Answers3

0

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
  • 13,815
  • 5
  • 29
  • 40
0

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

0

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
  • 13,959
  • 3
  • 55
  • 95