Link to home
Start Free TrialLog in
Avatar of hgbdelphi
hgbdelphi

asked on

how can i get mySystem name in javaBean?

hi,experts    

public class XSqlAction{
   String userdir=System.getProperties().getProperty("user.dir");  //
  //after run userdir="E:\resin-3.0.12"
 
}

my system in
E:\resin-3.0.12\webapps\track
how can i get it in XSqlAction?????
Avatar of Mick Barry
Mick Barry
Flag of Australia image

You need the Servlet COntext instance to access that, something like:

context.getRealPath("/");
Avatar of hgbdelphi
hgbdelphi

ASKER

hi,objects
 i not want to use Servlet Context,can i define my systemname in system var(like $mysystem="track") or define in classpath,and how can i get it ??/

thanks!
Yes, you could set a system property using System.setProperty()
in windows's system property ,i set jbasConfigSystem="track"
how can i get it
  System.out.println("mydefine:"+System.getProperties().getProperty("jbasConfigSystem"))

it is mydefine:null

how can i get it.
> in windows's system property

not in windows properties, you need to set it in java system properties
but if i  set it in java system properties,i need to write  code to do it ,i want not to do it ,and i define in window property,and in class,i read it and use it.but i do not know how can i read it in my class,please help,thanks!
you can specify system properties on the command line

java -DjbasConfigSystem=E:/resin-3.0.12/webapps/track ......
but this is j2ee project,i can not do it.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ha,thanks,in loadServlet,i set System.setProperty("myname","track")

and when i use i get System.getProperty("myname")

thanks!

Best Regard for objects !!!
hi,objects
 sorry,now i have 2 content,if i use System.setProperty("myname","track"),and System.getProperty("myname"),it will overwrite the first set myname,and how can i do it???

Thanks!