How to get system temp dir. path on the fly ,system may be XP or Linux ??

How to get system temp dir. path on the fly ,system may be XP or Linux ??
please suggest solution

The default temporary-file directory can be retrieved
using:
System.getProperty("java.io.tmpdir")
Thanks a lot for u r reply this one works !!!!

Similar Messages

  • How to get and disply dynamic values on the fly and display in applet

    hello all ,
    i have a problem in refreshing a applet.
    i have a scrolling applet which will get the share values from the database and display in a scrolling applet in the browser . i am getting the values and displaying it.
    but the problem is , if i enter a new record in the database, until and unless i press refresh button of the browser, i am not getting the new values . please help me if anybody having the idea. please mail me to [email protected]
    thank you all.
    by
    samba

    You want a database update to trigger an applet refresh? Can't be done.
    However, you can have the applet periodically re-query the database and update its display with the information it retrieves. Just kick off a Thread that sleeps for a bit, wakes up, queries the db, updates the display, and goes back to sleep.

  • How to get system Environment variable?

    How to get system Environment variable without using jni?
    just like "JAVA_HOME" or "PATH"...
    Any reply is help to me!! :-)

    Thx for your reply...
    I get it!!!
    Read environment variables from an application
    Start the JVM with the "-D" switch to pass properties to the application and read them with the System.getProperty() method. SET myvar=Hello world
    SET myothervar=nothing
    java -Dmyvar="%myvar%" -Dmyothervar="%myothervar%" myClass
    then in myClass String myvar = System.getProperty("myvar");
    String myothervar = System.getProperty("myothervar");
    This is useful when using a JAVA program as a CGI.
    (DOS bat file acting as a CGI) java -DREQUEST_METHOD="%REQUEST_METHOD%"
    -DQUERY_STRING="%QUERY_STRING%"
    javaCGI
    If you don't know in advance, the name of the variable to be passed to the JVM, then there is no 100% Java way to retrieve them.
    NOTE: JDK1.5 provides a way to achieve this, see this HowTo.
    One approach (not the easiest one), is to use a JNI call to fetch the variables, see this HowTo.
    A more low-tech way, is to launch the appropriate call to the operating system and capture the output. The following snippet puts all environment variables in a Properties class and display the value the TEMP variable. import java.io.*;
    import java.util.*;
    public class ReadEnv {
    public static Properties getEnvVars() throws Throwable {
    Process p = null;
    Properties envVars = new Properties();
    Runtime r = Runtime.getRuntime();
    String OS = System.getProperty("os.name").toLowerCase();
    // System.out.println(OS);
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set" );
    else {
    // our last hope, we assume Unix (thanks to H. Ware for the fix)
    p = r.exec( "env" );
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String line;
    while( (line = br.readLine()) != null ) {
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    envVars.setProperty( key, value );
    // System.out.println( key + " = " + value );
    return envVars;
    public static void main(String args[]) {
    try {
    Properties p = ReadEnv.getEnvVars();
    System.out.println("the current value of TEMP is : " +
    p.getProperty("TEMP"));
    catch (Throwable e) {
    e.printStackTrace();
    Thanks to W.Rijnders for the W2K fix.
    An update from Van Ly :
    I found that, on Windows 2003 server, the property value for "os.name" is actually "windows 2003." So either that has to be added to the bunch of tests or just relax the comparison strings a bit: else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows 2003") > -1 ) // works but is quite specific to 2003
    || (OS.indexOf("windows xp") > -1) ) {
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 20") > -1 ) // probably is better since no other OS would return "windows" anyway
    || (OS.indexOf("windows xp") > -1) ) {
    I started with "windows 200" but thought "what the hell" and made it "windows 20" to lengthen its longivity. You could push it further and use "windows 2," I suppose. The only thing to watch out for is to not overlap with "windows 9."
    On Windows, pre-JDK 1.2 JVM has trouble reading the Output stream directly from the SET command, it never returns. Here 2 ways to bypass this behaviour.
    First, instead of calling directly the SET command, we use a BAT file, after the SET command we print a known string. Then, in Java, when we read this known string, we exit from loop. [env.bat]
    @set
    @echo **end
    [java]
    if (OS.indexOf("windows") > -1) {
    p = r.exec( "env.bat" );
    while( (line = br.readLine()) != null ) {
    if (line.indexOf("**end")>-1) break;
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    hash.put( key, value );
    System.out.println( key + " = " + value );
    The other solution is to send the result of the SET command to file and then read the file from Java. ...
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set > envvar.txt" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set > envvar.txt" );
    // then read back the file
    Properties p = new Properties();
    p.load(new FileInputStream("envvar.txt"));
    Thanks to JP Daviau
    // UNIX
    public Properties getEnvironment() throws java.io.IOException {
    Properties env = new Properties();
    env.load(Runtime.getRuntime().exec("env").getInputStream());
    return env;
    Properties env = getEnvironment();
    String myEnvVar = env.get("MYENV_VAR");
    To read only one variable : // NT version , adaptation for other OS is left as an exercise...
    Process p = Runtime.getRuntime().exec("cmd.exe /c echo %MYVAR%");
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String myvar = br.readLine();
    System.out.println(myvar);
    Java's System properties contains some useful informations about the environment, for example, the TEMP and PATH environment variables (on Windows). public class ShowSome {
    public static void main(String args[]){
    System.out.println("TEMP : " + System.getProperty("java.io.tmpdir"));
    System.out.println("PATH : " + System.getProperty("java.library.path"));
    System.out.println("CLASSPATH : " + System.getProperty("java.class.path"));
    System.out.println("SYSTEM DIR : " +
    System.getProperty("user.home")); // ex. c:\windows on Win9x system
    System.out.println("CURRENT DIR: " + System.getProperty("user.dir"));
    Here some tips from H. Ware about the PATH on different OS.
    PATH is not quite the same as library path. In unixes, they are completely different---the libraries typically have their own directories. System.out.println("the current value of PATH is: {" +
    p.getProperty("PATH")+"}");
    System.out.println("LIBPATH: {" +
    System.getProperty("java.library.path")+"}");
    gives the current value of PATH is:
    {/home/hware/bin:/usr/local/bin:/usr/xpg4/bin:/opt/SUNWspro/bin:/usr/ccs/bin:
    /usr/ucb:/bin:/usr/bin:/home/hware/linux-bin:/usr/openwin/bin/:/usr/games/:
    /usr/local/games:/usr/ccs/lib/:/usr/new:/usr/sbin/:/sbin/:/usr/hosts/:
    /usr/openwin/lib:/usr/X11/bin:/usr/bin/X11/:/usr/local/bin/X11:
    /usr/bin/pbmplus:/usr/etc/:/usr/dt/bin/:/usr/lib:/usr/lib/lp/postscript:
    /usr/lib/nis:/usr/share/bin:/usr/share/bin/X11:
    /home/hware/work/cdk/main/cdk/../bin:/home/hware/work/cdk/main/cdk/bin:.}
    LIBPATH:
    {/usr/lib/j2re1.3/lib/i386:/usr/lib/j2re1.3/lib/i386/native_threads:
    /usr/lib/j2re1.3/lib/i386/client:/usr/lib/j2sdk1.3/lib/i386:/usr/lib:/lib}
    on my linux workstation. (java added all those execpt /lib and /usr/lib). But these two lines aren't the same on window either:
    This system is windows nt the current value of PATH is:
    {d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;c:\depot\cdk\main\cdk\bin;c:\depot\
    cdk\main\cdk\..\bin;d:\OrbixWeb3.2\bin;D:\Program
    Files\IBM\GSK\lib;H:\pvcs65\VM\win32\bin;c:\cygnus
    \cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;D:\orant\bin;C:\WINNT\system32;C:\WINNT;
    C:\Program Files\Dell\OpenManage\Resolution Assistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}
    LIBPATH:
    {D:\jdk1.3\bin;.;C:\WINNT\System32;C:\WINNT;d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;
    c:\depot\cdk\main\cdk\bin;c:\depot\cdk\main\cdk\..\bin;
    d:\OrbixWeb3.2\bin;D:\Program Files\IBM\GSK\lib;
    H:\pvcs65\VM\win32\bin;c:\cygnus\cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;
    D:\orant\bin;C:\WINNT\system32;
    C:\WINNT;C:\Program Files\Dell\OpenManage\ResolutionAssistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}

  • How to get system status and user status of service order

    Hi,
    I want to show user status and system status for service order in my report and i am using CRM_ORDER_READ function module to read the status, but it is returning lot of status records, could anyone please suggest how to get the system status and user status for service order.
    I did not find any clue for how to get user status, i can see the user status when i open the transaction using CRMD_ORDER.
    Regards,
    Kamesh Bathla

    Hi,
      Go to CRM_JEST table give your service order guid and get the status, pass this status into TJ02. You will get the status of your order.
    Regards
    Srinu

  • How to get javahelp release install path?

    How to get javahelp release install path?
    currently usage their tool <MagicHelp>.
    magichelp is multi-user help authoring tool,
    currently Support Java help 1.0/2.0.
    Home:http://www.gethelpsoft.com

    @BalusC
    ust for a reference cause i'm new in JSP This has nothing to do with JSP, but with basic knowledge of an essential API. I have given you the link to the File API. Are you saying that you refused to read the API documentation, which clearly explains you how to use the File and shows which methods are all available to you undereach the straightforward getName() method, and expecting that the others may chew the answers for you? Loser.

  • How to get System status Check Boxes into Query selection screen

    Dear experts,
    Pleas help in knowing how to get System status Check Boxes into quick view query (SQVI), selectionscreen.
    Regards
    Jogeswara Rao
    Edited by: K Jogeswara Rao on Jul 6, 2010 7:26 PM

    Problem solved through other Forum
    (Checkboxes not possible, some alternative solution to my requirement found)

  • How to get system idle time

    Hello Sir,
    I am Udhaya. I don't know how to capture system idle time using java. Please any one help me how to get system idle time. Any class is available in java to get idle time?
    Thank in advance
    Udhaya

    jwenting wrote:
    DrLaszloJamf wrote:
    jwenting wrote:
    the moment you ask the system for its idle time that idle time becomes 0, so just returning a constant value of 0 would always yield the correct answer.But when you don't call this constant method the value it would return is wrong. This is the sort of thing that keeps me up at night.Except of course that when you don't call it it doesn't return it and therefore still behaves properly.
    Or were you thinking of philosphical problems like "what does a method do when it's not called?"?Actually I was trying to see if I could get the OP to say boo to a goose.

  • How to get system status and user status ?

    how to get system status and user status for the given production order?
    In which PP table we can
    find these?
    Thanks&Regards
    Satish

    Hi Ram,
    Use the FM "STATUS_READ" to read both the system and user statuses for an Order.
    Alternatively, the following tables store the user and system status info:
    JSTO- Status object information
    JEST- Individual Object Status
    Hope this helps.
    Let me know if u need further information.
    Regards,
    Sonal

  • How to get system date??

    hi,can anybody tell me how to get system date in essbase?? i want to use it in calc script..Ayan

    The other thing you could do would be to write a custom macro or function to pull in the date or pass members to to do the comparisonGlenn S.

  • [ASK] How to get system date and substring / concate in data manager dynami

    Hello guys.
    I want to run package DM with the input have default value.
    The selection is look like this :
    Dimension : CATEGORY
    Source : PLAN_2011
    Destination : FORECAST_2011
    Dimension : TIME
    Source : 2011.JAN,2011.FEB,2011.MAR,2011.APR,2011.MAY,2011.JUN,2011.JUL,2011.AUG,2011.SEP,2011.OCT,2011.NOV,2011.DEC
    Destination : <same>
    How to get system date year and do the substring / concate ?
    So dimension category source will be PLAN_<YYYY>, destination = FORECAST_<YYYY>
    Dimension source = <YYYY>.JAN,<YYYY>.FEB,<YYYY>.MAR,<YYYY>.APR,<YYYY>.MAY,<YYYY>.JUN,<YYYY>.JUL,<YYYY>.AUG,<YYYY>.SEP,<YYYY>.OCT,<YYYY>.NOV,<YYYY>.DEC
    Depend on year system date.
    Thank you.

    Stuart,How are you storing OnSaleDate. If you are using OnSaleDate as an attribute dimension then you can write a Custom Defined Function to either:1- query your system for the current date and return the number of seconds that have elapsed since 1/1/1970. This is by definition the begining of the Epoch and how Essbase treats Attribute Dimensions of the Date type.public static long getDateInSeconds() {           Calendar cal = Calendar.getInstance();           return cal.getTime().getTime()/1000;}2- Write a Custom Defined Function that will accept the OnSaleDate and return the number of days sincepublic static double daysSince(double myDate) {     return (getDateInSeconds()-myDate )/86400;}

  • How to get system date and time?

    Can someone show me a code on how to get system date and time.
    Thanks!

    there is one really easy way to get system time, the api gives a great example of code on this. use gregorian calendar, which you'll find in the api under GregorianCalendar. You only need to create one instance of GC, ie Calendar time = new GregorianCalendar();
    you save seconds, minute and hours into int values, so you don't have to access the system time every second, you can create a thread which adds one to the int second value, if oyu see what i mean, for example, i have saved the hours, minutes and seconds as int values;
    int hour, minute, second;
    i can then create a thread (Thread thread = new Thread(this) and run it like:
    Calendar time;
    int hour, minute, second;
    Thread thread = null;
    public MyTime() {
    hour= time.get(Calendar.HOUR_OF_DAY);
    minute = time.get(Calendar.MINUTE);
    second = time.get(Calendar.SECOND);
    if(thread == null) {
    thread = new Thread(this);
    thread.start();
    public void run() {
    Thread t = Thread.currentThread();
    while(thread == t) {
    thread.sleep(1000);
    second++;
    if(second > 59)
    minute++;
    if(minute>59)
    hour++;
    formatTime();
    public void formatTime() {
    second = (second > 59? 0 : second);
    minute = (minute > 59? 0 : minute);
    hour = (hour > 23? 0 : hour);
    System.out.println(hour+":"+minute+":"+second);
    public static void main(String[] args) {
    new MyTime();
    I know this looks like gibberish but it should work. If not, try to fix the problem, i have written from memory really but i guarantee you, this gets the time then every second, simply adds one to the second and then formats time. You can also access the day, month and year then format them using the above code. I don't like giving code since you should really do these things yourself but it is 2:04am, i have nothing better to do and i am not tired so i did you a favour - i have become what i always did not want to, someone ho stays upall night writing code.

  • How to find out web-inf path from the physical drive?

    How to find out web-inf path from the physical drive?
    I have some user profiles in web-inf directory.SO I want to know the path from root directory like
    d:/program files/allaire/jrun/appname/web-inf/profiles/username like that.
    Presently I am able to get the path upto the application directory and from that I am concatinationg web-inf/profiles/username .
    But it is giving problems when it is deployed under unix or linux.Because web-inf there it treats as WEB_INF
    SO I want to get the path of web-inf directory with out hard coding.
    Thanku

    String path = application.getRealPath("/WEB-INF/profiles/username");
    Note sure why you need this, but you don't need the real path to read the file - you can get an InputStream using the relative path. See ServletContext getResource() and getResourceAsStream().

  • HT4792 how to get imovie to show up in the apps on iTunes?

    i tried to follow the steps on how to get imovie projects to ipone but the imovie app doesnt show up in the apps on itunes.

    So, when you go in to System Preferences > Print & Fax > Set Up fax Modem ..., Internal Modem is NOT showing up in Fax List?
    Does Internal Modem.app exist in /Users/{shortUserName}/Library/Printers/?

  • HT5422 How to get an better screen-update? The view on the remote Mac is nearly static.

    How to get an better screen-update? The view on the remote Mac is nearly static.

    You can try reducing the bit depth of the screen image  via the slider in the upper-right of the Control window. If that doesn't help, you may just not have a sufficiently fast network connection to correctly handle the data transfer necessary. This is often the case if you're connecting across the Internet. What is your network speed between the administration system and the client?
    Regards.

  • How to get online apps to work with the Verizon DSL modem firewall set at "Medium" level, not "Low?"

    How to get online apps to work with the Verizon DSL modem firewall set at “Medium” level? Xbox 360 Live, FTP, and the Windows sntp Time checker native to Windows XP WON’T WORK unless the Verizon firewall is first reset down to “Low.” Then all works well, but I then risk low firewall protection. Setup: · Westell 6100 DSL modem (Software Version: VER:4.04.03.00 Transceiver Revision: 7.2.3.0 Model Name: C90-610015-06), · D-Link DIR-655 wireless router (Hardware Version: A3, Firmware Version: 1.21), For Xbox 360 Live the “canned” port forwarding rule for provided in Verizon’s drop-down list for the Westell 6100 modem forwards ports 88 and 3074 for both TCP and UDP. This does not meet Microsoft’s forwarding recommendations for Xbox 360 Live stated at http://support.microsoft.com/kb/908874. Instead, for the Verizon modem (Westell) I made a new port forwarding rule to comply with those Microsoft instructions. It forwards ports 53, 80 and 3074 for TCP and ports 53, 88 and 3074 for UDP. These same ports are also forwarded in the D-Link router configuration. For FTP, port 21 is also forwarded for TCP and UDP in both modem and router. But they don’t work until I first cripple the Verizon firewall down to “Low.” How to get them to work with the Verizon firewall up to Medium?

    While I do not know the answer to your question, BUT since you have this modem and another router - you could just follow.
    http://www.dslreports.com/faq/13600
    ^^
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

Maybe you are looking for