inditrozen
asked on
Absolute path for the class at runtime.
Hi All,
It is required to get the absolute path of the current directory where my class is residing. This has to happen during runtime inside application server.
Following solutions in the internet were not useful for me.
1)
URL classFileDir = new TestAnything().getClass(). getResourc e("./");
2)
System.out.println(System. getPropert y("user.di r"));
3)
File currDir = new File(".");
System.out.println ( "Dir : " + currDir );
System.out.println ( "Dir : " + currDir.getCanonicalPath() );
Any other idea?
Best Regards
It is required to get the absolute path of the current directory where my class is residing. This has to happen during runtime inside application server.
Following solutions in the internet were not useful for me.
1)
URL classFileDir = new TestAnything().getClass().
2)
System.out.println(System.
3)
File currDir = new File(".");
System.out.println ( "Dir : " + currDir );
System.out.println ( "Dir : " + currDir.getCanonicalPath()
Any other idea?
Best Regards
ASKER
Thx for reply
I do not have session available in this class.
I do not have session available in this class.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no obj
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
Vee_Mod
Community Support Moderator
try,
ServletContext context = session.getServletContext(
String realContextPath = context.getRealPath(reques