Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Source dir

  Asked By: Jason    Date: Jun 23    Category: Java    Views: 514
  

I need to get the full path to the executed class files? Is there any
way to do this?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Anuja Shah     Answered On: Jun 23

I ran this test class  with JDK1.4_02

import java.security.CodeSource;
import java.security.ProtectionDomain;

public class TestLocation
{

public TestLocation(){
System.out.println("This is the sample constructor");
}

public static void main(String args[]){
try{
System.out.println("Code ----Location---" +
Class.forName("TestLocation").getProtectionDomain().getCodeSource().getLocation(\
));
}catch(ClassNotFoundException e){
System.out.println("---The exception " + e);
}
}
}

and the output was

Code ----Location---file:/D:/JDev905/jdev/mywork/Test/Java/classes/

 
Didn't find what you were looking for? Find more on Source dir Or get search suggestion and latest updates.




Tagged: