Question: I want to call the Autoit.exe file in the java class. I kept the AutoIt.exe file inside the executable package and read it in UploadProfile.java class.

```
// Label: image
driver.findElement(By.id("uploadimage")).click();
//for 1mb file uploading
Runtime.getRuntime().exec("D:\\netxploretesting\\unifytreewebautomation\\src\\test\\java\\executables\\fileupload.exe"+" "+"E:\\images\\profile.JPG");
//assertion for message display
assertTrue(driver.findElement(By.xpath("//strong[contains(text(),\"You are exceeding the size limit, it can't be more\")]")).getText().matches("You are exceeding the size limit, it can't be more than 512 KB."));
System.out.println(driver.findElement(By.xpath("//strong[contains(text(),\"You are exceeding the size limit, it can't be more\")]")).getText());

```

i want to change "Runtime.getRuntime().exec("D:\netxploretesting\unifytreewebautomation\src\test\java\executables\fileupload.exe"+" "+"E:\images\profile.JPG");" this code because when i execute to other system that time i change the file path

Answer: 
You can distribute exe with your package and keep it in sources but it is actually a sort of bad practice. However if you have no options I can suggest the following way:

1. Put your `exe` file to `resources` folder
2. Within the code implement copying the file from `resources` to some place in the file system.
3. Execute that file from the code
4. Build `jar` (`exe` file will be placed as a `resource` to your `jar`)

Below is a simple example on how you can achieve points 2 and 3:

```
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws InterruptedException, IOException {

        // Copy file from resources to file system (path taken from the command line argument)

        InputStream is = Main.class.getResourceAsStream("Autoit.exe");
        File exeFile = new File(args[0]);
        FileOutputStream fos = new FileOutputStream(exeFile);
        byte bytes[] = new byte[1000];
        int k = 0;
        while((k = is.read(bytes)) != -1){
            fos.write(bytes, 0, k);
        }
        fos.close(); // Do not forget to close the outputstream, otherwise your code will be holding the file and it won't be possible to execute it

        // Below is just an example on how you can execute the file after copying
        List<String> commands = new ArrayList<String>();    //
        commands.add(args[0]);                              //  Start file with argument
        commands.add("E:\\images\\profile.JPG");                             //
        Process p = new ProcessBuilder().command(commands).start();
        InputStream i = p.getInputStream();         //
        Scanner scanner = new Scanner(i);           //
        while (scanner.hasNextLine()){              //  Print the output of the file
            System.out.println(scanner.nextLine()); //
        }                                           //
    }

}

```

In this example we have our `your_application.exe` file in `resource` folder. We also take the destination for the file copying from command line arguments. So the way how to execute the `jar` will look like:

```
java -jar mysuper.jar c:/Folder_To_Store_Copy_Of_Autoit/Autoit.exe

```
if you want to run executable file as per system changes.
then save the executable file at project level.
and then call System.getPropert("user.dir") this will return your project path.
then add the package path which contains executable file. like below.
Runtime.getRuntime().exec(System.getProperty("user.dir")+"your package\file.exe")