티스토리 뷰
String sPath = System.getProperty("java.class.path");
System.out.println(sPath);
// 결과 : /home/udell/workspace/170112ClusteringEx/target/test-classes:/home/udell/workspace/170112ClusteringEx/target/classes:/home/udell/.p2/pool/plugins/org.junit_4.12.0.v201504281640/junit.jar:/home/udell/.p2/pool/plugins/org.hamcrest.core_1.3.0.v201303031735.jar:...
// 분리
String[] classpathEntries = sPath.split(File.pathSeparator);
sPath = new File(".").getAbsolutePath();
System.out.println(sPath);
// 결과 : /home/udell/workspace/170112ClusteringEx/.
sPath = this.getClass().getResource("Prac_1_Mahout.class").toString();
System.out.println(sPath);
// 결과 : file:/home/udell/workspace/170112ClusteringEx/target/classes/com/dogcowking/dev/prac/Prac_1_Mahout.class
sPath = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
System.out.println(sPath);
// 결과 : /home/udell/workspace/170112ClusteringEx/target/classes
'SW개발' 카테고리의 다른 글
A cycle was detected in the build path of project ... / ClassNotFound (0) | 2018.07.29 |
---|---|
Tomcat8 Heap memory size (0) | 2018.06.14 |
자바 환경변수 가져오기 등 (0) | 2018.06.06 |
Cannot change version of project facet Dynamic Web Module to 2.5 (0) | 2018.05.03 |
Maven Update 후 자바 버전이 바뀌는 현상 해결 (2) | 2018.05.03 |