• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hot to get package name programmatically  RSS feed

 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose our application is in package abc
and we use Ystem.getProperty("user.dir");
I get path as E:\jdk1.3.1\demo\applets\Clock
and not
E:\jdk1.3.1\demo\applets\Clock\abc
can any one tell me how to get the programmatically package name of the class in which we are working
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
URL url = getClass().getResource(".");
File directory = new File(url.getFile());
if you want the directory. The full package name is in getClass().getName(), if that's all you want.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!