0

I'm trying toopen/execute another program, which is a .jar file, but I'm getting the following error:

it is not a windows application

(java.io.IOException: CreateProcess error=193)

Here is my code:

import java.io.IOException;

public class Test8 {

    public static void main(String[] args) {

        try {

            String filepath = "C://Users//Alex//Desktop//Speedtest.jar";

            Process p = Runtime.getRuntime().exec(filepath);

        } catch (IOException e) {

            e.printStackTrace();
        }

    }

}

1 Answer 1

1

At the command-line, JARs are executed with java -jar. Try passing a String array:

String[] args = new String[] {"java", "-jar", "/path/to/myJar.jar"};
Process p = Runtime.getRuntime().exec(args);
Sign up to request clarification or add additional context in comments.

2 Comments

ok i tried this and there is still the same error, that it is no windows program:
Cannot run program "Speedtest.jar": CreateProcess error=193, %1 ist keine zulässige Win32-Anwendung at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.