[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how can i get mySystem name in javaBean?

Posted on 2005-04-29
11
Medium Priority
?
232 Views
Last Modified: 2012-05-05
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?????
0
Comment
Question by:hgbdelphi
  • 6
  • 5
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13899622
You need the Servlet COntext instance to access that, something like:

context.getRealPath("/");
0
 

Author Comment

by:hgbdelphi
ID: 13899738
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!
0
 
LVL 92

Expert Comment

by:objects
ID: 13899745
Yes, you could set a system property using System.setProperty()
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:hgbdelphi
ID: 13899769
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.
0
 
LVL 92

Expert Comment

by:objects
ID: 13899780
> in windows's system property

not in windows properties, you need to set it in java system properties
0
 

Author Comment

by:hgbdelphi
ID: 13899810
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!
0
 
LVL 92

Expert Comment

by:objects
ID: 13899817
you can specify system properties on the command line

java -DjbasConfigSystem=E:/resin-3.0.12/webapps/track ......
0
 

Author Comment

by:hgbdelphi
ID: 13899821
but this is j2ee project,i can not do it.
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 13899826
then set it from a startup servlet or a similiar place.
0
 

Author Comment

by:hgbdelphi
ID: 13899838
ha,thanks,in loadServlet,i set System.setProperty("myname","track")

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

thanks!

Best Regard for objects !!!
0
 

Author Comment

by:hgbdelphi
ID: 14751224
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!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question