如何获取应用程序';Java中的安装路径?
我将一些可执行文件打包到安装程序中,我想知道如何获取应用程序的安装路径(Win/Mac)。可执行文件位于安装目录下 您可以使用此命令获取用户工作目录(linux中的pwd)如何获取应用程序';Java中的安装路径?,java,windows,macos,path,Java,Windows,Macos,Path,我将一些可执行文件打包到安装程序中,我想知道如何获取应用程序的安装路径(Win/Mac)。可执行文件位于安装目录下 您可以使用此命令获取用户工作目录(linux中的pwd) String workingDirectory = System.getProperties().getProperty("user.dir"); URL jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation(); 您可以使
String workingDirectory = System.getProperties().getProperty("user.dir");
URL jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation();
您可以使用以下命令获取.jar文件位置:
String workingDirectory = System.getProperties().getProperty("user.dir");
URL jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation();
您可以使用此命令获取用户工作目录(linux中的pwd)
String workingDirectory = System.getProperties().getProperty("user.dir");
URL jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation();
您可以使用以下命令获取.jar文件位置:
String workingDirectory = System.getProperties().getProperty("user.dir");
URL jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation();
您可以将路径放入字符串中,如下所示:
String workingDirectory = System.getProperties().getProperty("user.dir");
或打印:
System.out.println(System.getProperties().getProperty("user.dir"));
您可以将路径放入字符串中,如下所示:
String workingDirectory = System.getProperties().getProperty("user.dir");
或打印:
System.out.println(System.getProperties().getProperty("user.dir"));
尝试此操作,是否“user.home”
返回用户的主目录但不返回安装路径?尝试此操作,是否“user.home”
返回用户的主目录但不返回安装路径?