将外部jar文件添加到类路径

时间:2017-04-06 08:37:02

标签: java jar classpath

我想在我的应用程序路径中添加一个外部jar,这是我的代码,但它没有用。

代码:

final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
        File Jar = null;
        try {
            Jar = new File(MyApp.class.getProtectionDomain().getCodeSource().getLocation().toURI());
        } catch (URISyntaxException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

          final ArrayList<String> command = new ArrayList<String>();
          command.add(javaBin);
          command.add("-classpath");
          command.add("\""+"C:\\path to file\\file.jar"+"\""+" ");
          command.add(Jar.getPath());
          Restart();

0 个答案:

没有答案
相关问题