Results 1 to 7 of 7
- 07-04-2011, 12:00 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
- 07-04-2011, 12:35 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Why do you want to know that? It could be me but I don't see any use for it.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-04-2011, 12:36 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
- 07-04-2011, 12:38 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 07-04-2011, 12:40 PM #5
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
- 07-04-2011, 12:49 PM #6
Have you read the API for the classes returned by those methods? No? Why not?
db
- 07-04-2011, 12:55 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
I still don't know why you want to know the location (file) where your class came from; it smells like bad design, but I just checked the API docs and this should be a way to do it:
kind regards,Java Code:Class c= Class.forName("your.complete.class.name"); // or any other way to obtain a Class object ProtectionDomain pd= c.getProtectionDomain(); CodeSource cs= pd.getCodeSource(); System.out.println(cs.getLocation());
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Output Jar Filename
By CuddlyKittens11 in forum NetBeansReplies: 0Last Post: 04-25-2011, 01:09 AM -
filename as a string
By Saran185 in forum New To JavaReplies: 6Last Post: 02-13-2011, 01:19 AM -
cannot find the class file when running the java command
By kulangotski in forum New To JavaReplies: 4Last Post: 01-18-2011, 11:34 AM -
New filename after try catch
By hellzxmaker in forum New To JavaReplies: 3Last Post: 11-05-2010, 11:07 PM -
Compiling/Running Project in Command Line: "Could not find main class" Error
By Yasemin Gokce in forum New To JavaReplies: 1Last Post: 06-30-2009, 02:32 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks