In my java app I open an exe with ProcessBuilder and that exe makes something, this exe needs some files and I located them in my jar root directory but when I run jar with double click I get file not exist error but when I run app from terminal everything is success.

by the way with double click getProperty("user.dir") gets wrong path but from terminal it gets right path.

Source code:

             String exeCommand = "pathtoexe";

             String[] arguments= new String[] { exeCommand,
                    "arg1", "arg2","arg3" };

             ProcessBuilder proc=new  ProcessBuilder(arguments).start();

                    InputStream out = proc.getInputStream();

                    BufferedReader input = new BufferedReader(
                            new InputStreamReader(out));
                    boolean isSuccess = false;
                    String line = null;

                    while ((line = input.readLine()) != null) {
                        if (line.contains("OK")) {
                            isSuccess = true;
  • ... and? What's your problem? That is the intended behaviour. If it is intended to be launched with double click probably you should rewrite it better. – dadexix86 Dec 13 '15 at 12:16
  • my problem is when I run with double click exe not find files that needed, and it is not intended how make it be able to find files? – Numan KIZILIRMAK Dec 13 '15 at 12:29
  • 1
    Just rewrite the program, using the right functions and places of that files. Probably the program looks for something like "here", where "here" is taken from the launching path. When you launch it with double click, that is not defined properly. So you should simply rewrite the program, but better :) Or use it via terminal. Or you can try to put that files in the right path for the program you are using (maybe directly in your home? I don't know that the program is...) – dadexix86 Dec 13 '15 at 12:31
  • what do you mean with rewrite the program? the files must be in the root directory and I ask what is the solution cause with double click app cant find files. And I can not locate that files to location that user.dir shows, cause I have so many versions of that files with same names and end user can NOT use with terminal I shoul find solution for double click. – Numan KIZILIRMAK Dec 13 '15 at 14:09
  • The problem is how the program is written.. Do you have the source code? – dadexix86 Dec 13 '15 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.