Reputation: 123
I have a Java program for the graphical user interface. This Java program runs a C program which is already compiled. I create a JAR file in order to make my program executable. As a consequence my C program is included in the JAR file.
I use those lines :
String[] Tab_arg =new String[6];
Tab_arg[0]="./src/generalisation.exe";
Tab_arg[1]=fileM.getAbsolutePath();
Tab_arg[2]=fileG.getAbsolutePath();
Tab_arg[3]=fichGA_absolutePath;
Tab_arg[4]=fichGO_absolutePath;
Tab_arg[5]=fileR.getAbsolutePath();
try
{
Process p =Runtime.getRuntime().exec(Tab_arg);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
}
catch (IOException e)
{
e.printStackTrace();
}
The trouble is that the JAR file operates correctly on Ubuntu but not on Windows.
Upvotes: 0
Views: 343
Reputation: 1016
When you have compiled it for Windows, you could add the two versions (Linux and Windows) to the JAR file. In your code you could add this
if(System.getProperty("os.name").startsWith("Windows"))
Tab_arg[0]=".\src\generalisation.exe";
else
Tab_arg[0]="./src/generalisation";
This should do the trick if the Linux version has no extension.
Upvotes: 1