This is not about creating a batch file or executing a batch file from java but creating a binary from them.
I am not very sure about Linux shell scripts but is know that for Windows Batch scripts there are some programs like Batch to Exe Converter. But i want to do it programmatically.
Suppose I read the contents of a batch file from a file :
public static String loadFile(String filepath) {
List<String> lines = Collections.emptyList();
try
{
lines =
Files.readAllLines(Paths.get(filepath), StandardCharsets.UTF_8);
}
catch (IOException e)
{
e.printStackTrace();
}
String s = "";
for(String line:lines){
s += line + "\n"
}
return s;
}
Now i want to convert it to an exe
.
Purpose
My main purpose is to create small executables from those scripts for some small automations which will be used instead of the scripts themselves.
For example:-
I have a setup.bat
file.
I have my program to automatically generate the batch every time I make any changes(add files) now i also want to have executables along with the scripts.
I also a curious whether a similar thing is possible for Linux shell scripts(creating executables).
Moreover i this is not possible through Java directly can we some how do it using JNI?