For some context: I am currently developing a Java application that needs to execute an executable in the command line. But that's not what this question is about.

Now, usually you would pack all required resources of a Java application into a folder in /src/main/resources/, but a executable file will obviously not be usable then, except when I let the application extract said executable in runtime.

So how do I design such an application?

If I should store those resources next to my JAR file, is that even possible with tools like Maven or SBT, so those files get automatically moved from some resource folder next to the compiled JAR?

(In case that this question does not fit Software Engineering I apologise, but please give me a hint where to ask it otherwise.)

Edit: I am planning to provide the executable with my software.

  • Can you give a little more info on what this executable does, or the role it plays in the Java application? Commented Aug 29, 2018 at 16:57
  • Are you supplying this executable along with your JAR file? Commented Aug 29, 2018 at 19:21
  • @GregBurghardt The Java Application itself is just a wrapper around many different command line interactions. Before I started developing it in Java, I already wrote a prototype using Batch. But because Batch - or any non-typesafe and/or script-languages for that matter - are ugly to me, I wanted to write the same application using Scala. The Java ecosystem has great tools to work with the command line, so it's not even far-fetched. The Batch prototype already required to use two executables that came packed along with it. Commented Aug 30, 2018 at 7:18
  • @DanPichelman I am planning to do so, either packed next to the JAR, inside the JAR or with the installer. Commented Aug 30, 2018 at 7:19

1 Answer 1


Treat the executables as just another dependency to your Java application.

Deploy them all the exe files to the same root folder within your application. You can get the directory of a running jar file using class reflection, which should be the similar in Scala as Java. From that point on it's just a file path convention to invoke the executable.

You don't necessarily want to check the executables into your code base. You can have a separate repository just for the exe files that you'll need to pull down when developing locally. Separating the code base from the exe's allows you to deploy changes to each separately.

  • Okay, I guess same goes if someone else developed those executables? Commented Aug 30, 2018 at 11:20
  • @MarkusAppel: Yes. If someone else developed them, all you need is the executable file. It's not part of your code base. It's a dependency just like any other. Commented Aug 30, 2018 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.