Execute .exe on java, who require some library-Collection of common programming errors
agonist_I have a little problem today,I want to use this tool http://freecode.com/projects/jpegoptim on my java program. But on windows it’s only work with Cygwin after install jpeg library.
So my question is : How I can run it on my java program like :
String[] cmd = {"C:\\Users\\Bastien\\Desktop\\jpegoptim\\jpegoptim.exe", "some args"}; try { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(cmd);thanks if a solution exist.

Eugeny LoyIf you do not bother about distribution/licensing stuff – figure out what dll’s your app depend on and place them near to your exe.
That’s the easies way to “make it work”.
You have 2 general ways to determine what dll’s your app depend on:
-
Run app and see what it requires (windows should give you a message with missing dll) – nmot convenient bu most reliable.
-
Use static analysis tools like this to analyse exe dependencies – should work for most of the cases.
Be warned that this is rather ad-hoc method and I would not suggest you to do something like that in production.
-
Stephen CBy far the simplest approach is to install Cygwin.
If you can’t (or won’t) do that, there are a couple of things you could try, though neither is guaranteed to succeed:
-
You could download the source code and attempt to build it for native windows using your favourite Windows C or C++ (or whatever) compiler. If this fails (and it probably will), you could attempt port the code, replacing UNIX-specific library with the equivalent Windows library calls. Warning: you need some C / C++ and Windows programming skill to pull this off.
-
You could attempt to identify and provide all of the DLLs that the application needs to run. However, some of those DLLs will be part of Cygwin, so you’ll need to download Cygwin to get hold of them in the first place.
BEWARE: if your intent is to redistribute this, redistributing Cygwin DLLs in your installer (or whatever) may mean that your code needs to adhere to the terms of the Cygwin License. That is basically GPL 3+ with an exception. Alternatively you can get (i.e. pay for) a special license from RedHat. Either way, do your own research and/or get competent advice on the licensing implications.
-