0

I am developing a GUI using swing that runs an executable. Currently the executable is being used via Runtime.getRuntime().exec().

I have both the executable and the source code. If I compile my GUI into a jar the executable will not be included into as it currently stands, correct?

I would like the whole thing to run as a single file, is it better then to use the source code or can I package it all as one jar when I'm done some how?

Though I'm writing all the code by hand I do have WindowBuilder for eclipse, I haven't really explored it thoroughly, is there anything in there that might help?

EDIT: Sorry, to clarify: The GUI I want to build uses an executable called src2srcml to take a source file (C, C++, Java) and convert it to an XML File. src2srcml is a separate executable I got from this website: http://www.sdml.info/projects/srcml/

I want to embed this executable into my GUI so that when I compile my GUI into a JAR it contains src2srcml inside it so that I don't need to send a client both my GUI and src2srcml separately.

Nick
  • 862
  • 12
  • 35
  • There is such a thing as an "executable jar" which can be run as a single file. Any IDE offers the ability to export an executable jar (and usually asks you to specify if it is executable or just a library if I recall correctly). – gnomed Sep 16 '14 at 22:19

2 Answers2

3

If you include the executable within the Jar, the executable will not be runnable by the OS.

With that in mind, you have a number of choices...

You Could...

Design a build process that compiles and packages the jar file, takes that and the executable and copies it into an appropriate directory structure for distribution...possible even building installers...

This will mean that you can still access the executable at runtime by using a relative path

This does mean you will have at least two files you will need to distribute, but the over all process is relatively painless...

You Could...

Include the executable within the jar file. At runtime, you would need to extract the executable to the filesystem and execute it.

This means that you will have at least one file you will need to distribute, but it complicates the development process as you will need to find the resources (executable) at run time and extract it to some location before you can execute it

You Could...

Just build an installer for your application. Something like like izPack for example, or what ever installer you want to use.

This means that you can distribute a single file to the client, but when installed, it will unpack all the files into the installation location and you won't need to care...

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
0

I'm not sure if I understood your question, but if you want to export you application into jar file and you want it to include all dependecies just have a look at this SO question: How to create a jar with external libraries included in Eclipse?

Community
  • 1
  • 1
Lucas
  • 3,181
  • 4
  • 26
  • 45