Last active
August 28, 2021 10:12
-
-
Save wayoda/3d83ded3642e9531f731 to your computer and use it in GitHub Desktop.
Get the user.dir and codebase dir for a jar file invoked from the commandline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wayoda.arduino; | |
import java.util.Properties; | |
import java.io.File; | |
public class GetSystemPath { | |
public GetSystemPath() { | |
Properties p=System.getProperties(); | |
String userDir=p.getProperty("user.dir"); | |
try { | |
File jarDir=new File(GetSystemPath.class | |
.getProtectionDomain() | |
.getCodeSource() | |
.getLocation() | |
.toURI().getPath()); | |
File codeDir=jarDir.getParentFile(); | |
System.out.println(" Current user dir is : '"+userDir+"'"); | |
System.out.println(" Here is the jar-file : '"+jarDir+"'"); | |
System.out.println("The directory of the jar-file : '"+codeDir+"'"); | |
} | |
catch (Exception e) { | |
System.out.println(e); | |
} | |
} | |
public static void main(String [] argv) { | |
GetSystemPath gsp=new GetSystemPath(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Main-Class: org.wayoda.arduino.GetSystemPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment