0

I'm not experienced at all regarding java or programming in general.

However I would like to find out if this scenario is possible;

I run a JAR-file which asks for some input strings. The JAR-file use these strings to compile another JAR-file and a batch-file.

So far I tried a set-up like this: A java-project with three classes. One that asks for input, one that creates a batch-file, and the last class is the code for the new JAR-file.

To create a batch-file is no problem. But how can I in a class create a JAR-file?

I'm using Eclipse.

Thanks for your time!

Robert.

Robbas
  • 39
  • 1
  • 9
  • 2
    Possible duplicate of [How to create a runnable jar file from source code programmatically?](http://stackoverflow.com/questions/10237903/how-to-create-a-runnable-jar-file-from-source-code-programmatically) – Lajos Arpad Sep 27 '16 at 09:29

1 Answers1

0

Batch files can only be created on the disk, and then you can execute that file by the file location. But to run commands, you dont need to call batch file, you can easily call "cmd.exe" with the "/c" argument and execute commands directly. A very good example for the above: Run cmd commands through java

Let me know if you have more questions!

Community
  • 1
  • 1
  • Well, I'm not sure this is what I want. The scenario is this: I run a JAR-file, which asks for some input. I take this input to create a new JAR-file and BAT-file. The BAT-file will go to a server for scheduled running, which terminates a process and runs the second JAR. My idea is to be able to easily compile new JAR- and BAT-files, since they will always be the same except for some customer specific data, like extension, filepath etc (which should be input variables from the first JAR). – Robbas Sep 27 '16 at 09:37