พูดถึงว่ามีการตรวจสอบเฉพาะในWindowsแต่ฉันคิดว่ามันทำงานได้ดีในระบบปฏิบัติการอื่น ๆ [ Linux,MacOs,Solaris] :)
ฉันมี2 .jarไฟล์ในไดเรกทอรีเดียวกัน ฉันต้องการจาก.jarไฟล์หนึ่งเพื่อเริ่มต้นอื่น.jarไฟล์ซึ่งอยู่ในไดเรกทอรีเดียวกัน
ปัญหาคือว่าเมื่อคุณเริ่มต้นจากไดเรกทอรีปัจจุบันคือcmdsystem32
  คำเตือน!
- ด้านล่างดูเหมือนว่าจะทำงานได้ดีในทุกการทดสอบที่ฉันทำแม้จะมีชื่อโฟลเดอร์
;][[;'57f2g34g87-8+9-09!2#@!$%^^&()หรือ()%&$%^@#
ใช้งานได้ดี 
- ฉันใช้
ProcessBuilderกับด้านล่างดังต่อไปนี้: 
🍂 ..
//The class from which i called this was the class `Main`
String path = getBasePathForClass(Main.class);
String applicationPath=  new File(path + "application.jar").getAbsolutePath();
System.out.println("Directory Path is : "+applicationPath);
//Your know try catch here
//Mention that sometimes it doesn't work for example with folder `;][[;'57f2g34g87-8+9-09!2#@!$%^^&()` 
ProcessBuilder builder = new ProcessBuilder("java", "-jar", applicationPath);
builder.redirectErrorStream(true);
Process process = builder.start();
//...code
🍂 getBasePathForClass(Class<?> classs):
    /**
     * Returns the absolute path of the current directory in which the given
     * class
     * file is.
     * 
     * @param classs
     * @return The absolute path of the current directory in which the class
     *         file is.
     * @author GOXR3PLUS[StackOverFlow user] + bachden [StackOverFlow user]
     */
    public static final String getBasePathForClass(Class<?> classs) {
        // Local variables
        File file;
        String basePath = "";
        boolean failed = false;
        // Let's give a first try
        try {
            file = new File(classs.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
            if (file.isFile() || file.getPath().endsWith(".jar") || file.getPath().endsWith(".zip")) {
                basePath = file.getParent();
            } else {
                basePath = file.getPath();
            }
        } catch (URISyntaxException ex) {
            failed = true;
            Logger.getLogger(classs.getName()).log(Level.WARNING,
                    "Cannot firgue out base path for class with way (1): ", ex);
        }
        // The above failed?
        if (failed) {
            try {
                file = new File(classs.getClassLoader().getResource("").toURI().getPath());
                basePath = file.getAbsolutePath();
                // the below is for testing purposes...
                // starts with File.separator?
                // String l = local.replaceFirst("[" + File.separator +
                // "/\\\\]", "")
            } catch (URISyntaxException ex) {
                Logger.getLogger(classs.getName()).log(Level.WARNING,
                        "Cannot firgue out base path for class with way (2): ", ex);
            }
        }
        // fix to run inside eclipse
        if (basePath.endsWith(File.separator + "lib") || basePath.endsWith(File.separator + "bin")
                || basePath.endsWith("bin" + File.separator) || basePath.endsWith("lib" + File.separator)) {
            basePath = basePath.substring(0, basePath.length() - 4);
        }
        // fix to run inside netbeans
        if (basePath.endsWith(File.separator + "build" + File.separator + "classes")) {
            basePath = basePath.substring(0, basePath.length() - 14);
        }
        // end fix
        if (!basePath.endsWith(File.separator)) {
            basePath = basePath + File.separator;
        }
        return basePath;
    }
               
              
cdคำสั่งบน command-prompt ของคุณเมื่อคุณดำเนินการนี้