Is there a  System.getProperty("user.desktop")

I am trying to get the path of a user's desktop, regardless of OS.
I know that I can use
System.getProperty("user.home")to get the current user's directory, but what about the current user's desktop? is there a call for that?
if not, i know where the windows desktop folder is located, but I am unfamiliar with Mac, Linux, other Unix OSs...could anyone please share where their desktops are from the root dir?
thanks.

Two suggestions so far for Linux:
* /usr/local/foo
* user.home
The first will probably only be writable if your installer* is being run by root / superuser. I'd say that the expected behaviour would be to extract to pwd - i.e. user.dir. However, as already stated I'd quite like to be given the choice first if it's a GUI installer. A console installer which extracts to pwd would seem quite reasonable.
Of course, you could take the view that most Linux users are used to getting a .tgz which they then extract whereever they want, so if your jar contains the file it extracts it's probably sufficient to put a README.txt in it and prompt the Linux user to read it.
Under OS X people will probably expect you to use the built-in installer. You might be able to build a suitable package without an OS X box - check Apple's website for documentation. The desktop is ~/Desktop (where ~ is user.home).
* If it's not an installer, although you seem implicitly to have agreed it is, I'd extract to /tmp/fooRND, making sure that it didn't exist and generating a new RND if it did.

Similar Messages

  • System.getProperty("user.dir") cannot rerturn the package directory.

    i have a class belong to package suyuan
    the class file is located at
    D:\Profiles\cyc025\Desktop\suyuan\test.class
    i try to execute System.getProperty("user.dir") inside test.class.
    i get D:\Profiles\cyc025\Desktop
    but i wish there is a java api which can return
    D:\Profiles\cyc025\Desktop\suyuan
    how can i do so?
    thank you.
    regards
    yan cheng

    The system property "user.dir" returns the current working directory. The "suyuan" is a part of the java package of test.class - it has nothing to do with each other. If you want your string you need to create it via
    String pn = getClass().getName();
    int i = pn.lastIndexOf('.');
    pn = pn.substring(0, i);
    String mine = System.getProperty("user.dir") + File.separatorChar + pn;

  • System.getProperty("user.name") not working without /etc/passwd, CentOS 4.3

    Dear all,
    I'm having trouble getting the system property user.name (which we need in our ant scripts) on our CentOS box. :(
    When running the program below thru
    java dumpproperties2
    it prints "user.name='?'" on our CentOS 4.3. On win32 it works. It turns out that if you add the account corresponding to the EUID to /etc/passwd it works correctly. However, we don't use passwd authentication but an enterprise wide LDAP-system. Our /etc/nsswitch.conf says:
    passwd: files ldap
    One work around is to replace the java executable with a script that does
    /path/to/jdk/bin/java -Duser.name=$USER -Duser.home=$HOME $@
    Used jdk is j2se 1.5.0_13 Linux 32-bit.
    Some questions for the experts:
    1) Is there any other way?
    2) Is it a known issue that Linux versions of the jdk just looks in /etc/passwd to map uid to user name (and home dir) instead of doing what the rest of the system, like whoami, does? I haven't found anything in either the readme or installation instructions, nor in the bug db.
    Br, Jesper Tr�g�rdh
    public class dumpproperties2 {
        public static void main(String[] args) {
         String s = System.getProperty("user.name");
         System.out.println("user.name='" + s + "'");
    }

    Does this work?
    //public final class System
    public static String getenv(String name)Then you can access the USER environment from inside Java.

  • System.getProperty("user.dir") returns "/home/user" on Linux

    Has anyone else had the error when launching a jar from Linux (just by clicking it), System.getProperty("user.dir") returns the "/home/user" (or "~") value instead of the folder that the jar is in? Essentially, it returns "user.home" instead of "user.dir".
    This does not happen when I start the application from command line.
    (I know its not swing, but I wasn't sure where to post it)
    Is this just a simple Linux setting that isn't enabled by default? Ubuntu already made the file association after using apt-get to install Java 6.
    Cheers.
    -FBL

    Because, semmingly, the command is being set off as
    java -jar relative/pat/to/file.jarwhen you double click it, rather than
    cd relative/path/to
    java -jar file.jarIf you don't like this, I would say to find a Linux, preferably Ubuntu, forum and ask there if it is possible to change that handling, and if not, request that a cahnge be made to the code to change that handling. But, in any case, I doubt you are going to get an answer here about it.

  • System.getProperty("user.dir") different in Ubuntu?

    HI. I have this application which when the user presses the Help button an HTML user guide is shown.
    this is done using:
    String userDir = System.getProperty("user.dir");
    System.out.println(userDir);
    Desktop d = Desktop.getDesktop();
    File f = new File(userDir);
    URI u = new URI(f.toURI().toString()+"User_Guide/index.htm");
    System.out.println(u.toString());
    d.browse(u);This works on Windows machines, but when tested on Unix Ubuntu the user guide does now show.
    The System.getProperty("user.dir") returns users/j/john/ which is not the complete directory. How can I fix this so that the Help button works on both platforms?Thanks!
    Edited by: player123 on Jun 9, 2009 10:54 AM

    ++
    Make sure its Sun's Java no OpenJDK or others.
    $ java --version
    also echo $JAVA_HOME
    it depends how its linked on yours.
    Even if you install the Sun's JDK you must properly link it and/or set and export its home ;)

  • System.getProperty("user.region") in JDK version 1.3 vrs. 1.4

    Hi guys,
    I wonder why, when I set the following instruction to detect the regional settings, I got different results using 1.3.1 vrs. 1.4.1?
    String slRegion = System.getProperty("user.region");
    If I use 1.3.1 then I got the right result, but if I use 1.4.1 I got a null value.
    I need to use JDK 1.4.1, that's why I'm interested in getting the answer.
    TIA.

    As I want to know the 2 letters of the countries, such as:
    IN_USA = "US";
    ES_MEXICO = "MX";
    ES_ARGENTINA = "AR";
    ES_BOLIVIA = "BO";
    ES_CHILE = "CL";
    ES_COLOMBIA = "CO";
    ES_COSTARICA = "CR";
    ES_REPDOMINIC = "DO";
    ES_ECUADOR = "EC";
    ES_SALVADOR = "SV";
    What would it be the syntaxis (line code) to get this info?
    I appreciate your help

  • Where does user.name come from when using System.getProperty(user.name)

    Hello,
    Based on the user's requirements, I implemented authentication based on the results of the System.getProperty(user.name) feature. The audit group has some concerns on where the user.name value is coming from.
    Does anyone have any idea where this property is coming from, and if it is coming from a file, whether it is stored as text.

    Environment variable that is read internally by the JRE. If you go to dos (in windows) and type "set" and hit return, you'll see Username=whatever your login name is. If course, someone with the right credentials can change this.
    Unix has a similar feature.

  • System.getProperty("user.home") is giving diferent results on diff versions

    I am working on windows 2000. When I try to get user.home using System.getProperty it gives me c:\documents and settings\my name.
    But the same things when tried on a windows 2003 server tries to look in c:documents and settings\default directory. Why is this?
    Please help.....

    In XP, the environment variable USERPROFILE is set to C:\Documents and Settings\<username>, and that value is picked up for user.home. Since the "user's home directory" varies by os, there will be variations. 98 is different than Linux than XP, etc.

  • System.getProperty("user.dir")

    Hi has any1 got a help reference to explain this property and in particular if its platform specific?
    Where can I get a list of system properties
    Thanks

    If you look in the api under java.lang
    the class you are looking for is System
    look for the method getProperties()
    it lists all of the system properties that you can use :)

  • System.getProperty("pc.name") ???

    As the title of this post implies, I would like to get the PC name from within a client-side java app. Unfortunately "pc.name" is not a valid system property key. Nor are there any, as far as I can tell, that give me what I want.
    Can anybody tell me how a client-side app can get the name of the PC on which it is running?
    To be completely clear, I want the name that shows up when I click Start > Settings > Control Panel > System > Network Identification. (Yes, I'm running Win2K...)
    Thanks!
    Bill

    Hi,
    :. Try this one. Comments in Portuguese.
    class ... whatever you want, a library for instance.
      public static final String OS_WINDOWS        = "Windows";
      public static final String OS_LINUX          = "Linux";
      public static final int CMD_SUCCESS          = 0;
      // = = = = = = = = = = = = = = = = = = = = = = =
      // Carrega as variaveis de ambiente (#014)
      public static boolean loadEnvironmentVariables()
      { boolean bRet  = false;
        String cmd    = "";
        String opsys  = System.getProperty("os.name","");
        try
        { if (opsys.startsWith(OS_LINUX))   cmd = "sh -c set";
          if (opsys.startsWith(OS_WINDOWS)) cmd = "command.com /c set";
          if (!cmd.equals(""))
          { Process p = Runtime.getRuntime().exec(cmd);
            if (p.waitFor() == CMD_SUCCESS)
            { InputStream is = p.getInputStream();
              Properties pr  = new Properties(System.getProperties());
              pr.load(is);
              System.setProperties(pr);
              bRet = true;
        catch(Exception e) {}
        finally
          return bRet;
      // = = = = = = = = = = = = = = = = = = = = = = =
      // Hostname (#016)
      public static String getHostname()
      { String sRet  = "";
        String opsys = System.getProperty("os.name","");
        if (opsys.startsWith(OS_LINUX))
        { sRet = System.getProperty("HOSTNAME","");
        else if (opsys.startsWith(OS_WINDOWS))
        { sRet = System.getProperty("COMPUTERNAME","");
        return sRet;
      // = = = = = = = = = = = = = = = = = = = = = = =
      // Username (#017)
      public static String getUsername()
      { String sRet  = "";
        String opsys = System.getProperty("os.name","");
        if (opsys.startsWith(OS_LINUX))
        { sRet = System.getProperty("USER","");
        else if (opsys.startsWith(OS_WINDOWS))
        { sRet = System.getProperty("USERNAME","");
        return sRet;
    :. First, call loadEnvironmentVariables method then getUsername,  getHostname, etc. Hope it helps and it was what you meant.
    Regards.
    Roque.

  • Applet, System.getProperty question

    I am trying to develop a simple applet that would capture the NT user name with System.getProperty("user.name"). This will not work with servlet because it will only return the server user.name. With applets running on clients systems, I was hoping that this will work. My applet has only 1 button and 1 text field. It runs fine in a debug mode in Forte 2.0. It generates an error msg when I run in in Forte. It doesn't do anything if I add the class to a html file. Am I on the right track here or what do I need to do to get this to work?
    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
    String login = System.getProperty("user.name");
    textField1.setText(login);
    This works in a debug mode in Forte, but fails when I run it. This is the error message:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1278)
    at java.lang.System.getProperty(System.java:560)
    at LoginApplet.button1ActionPerformed(LoginApplet.java:40)
    at LoginApplet.access$0(LoginApplet.java:39)
    at LoginApplet$1.actionPerformed(LoginApplet.java:20)
    at java.awt.Button.processActionEvent(Button.java:329)
    at java.awt.Button.processEvent(Button.java:302)
    at java.awt.Component.dispatchEventImpl(Component.java:2595)
    at java.awt.Component.dispatchEvent(Component.java:2499)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
    at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

    Hi,
    As you can see you received a Security exception, for a good reason. If you could access a username and/or password then your computer could be compromised. Anyone could then write an unseen applet embedded in their web page that gathers username/password for any computer that requests the web page. The security manager on that specific PC (or web browser) would have to be modified specifically to allow this sort of access, which is not advised because then anyone else with this type of applet could get the same information that you are attempting to get (if you request a web page on another site with that applet requesting you system information).
    Hopefully this helps.

  • GetProperty("user.dir") Causing Exception

    I'm using the System.getProperty("user.dir") command to identify the current directory within Unix.
    Running the program within the directory it was compiled works great, but run it from anyother directory causes the following error
    Exception in thread "main" java.lang.NoClassDefFoundError: SortFiles
    Any ideas why ?
    Thanks
    class SortFiles {
    public static void main(String[] args) {
    String path = System.getProperty("user.dir");
    System.out.println(path);

    The error is nothing to do with System.getProperty()
    The error is thrown by the JVM because it can't find your class to begin with, it's not getting as far as your code because it cannot find it.
    Set your classpath (or use the -cp option) to run your class.
    System.getProperty("user.dir") should then return the director you ran your program from.

  • System.getProperty with foreign language

    Hello All,
    I've developed a program that uses System.getProperty("user.home"), in order to transfer files to that location.
    Everything's going well as long as I'm using English version.
    When one of my customers ran this using a foreign language (Turkish, but it seems to have the same effect on other languages), instead of c:\documents and settings\administrator, he got a wrong fonetic path, i.e. C:\DOCUMENTS AND SETTÝNGS\ADMÝNÝSTRATOR (check the I's, they're not the same), although he has the English path in his computer.
    You can see this also when you change the regional settings in an English based Windows to Turkish.
    How can I make the System property look at the correct path (again, this happens in other languages as well)?
    Thanks,
    Barak

    Hmmm.... I didn't think I used toUpperCase in my code. When all else fails, my advice is to read the API...
    [http://java.sun.com/javase/6/docs/api/java/lang/String.html#toUpperCase()]
    <quote>
    Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "title".toUpperCase() in a Turkish locale returns "T?TLE", where '?' is the LATIN CAPITAL LETTER I WITH DOT ABOVE character. To obtain correct results for locale insensitive strings, use toUpperCase(Locale.ENGLISH).
    </quote>

  • Is there a system table or V$ view that will show a user's last logon date?

    Is there a system table or V$ view that will show a user's last logon date?
    I'm using Oracle 9.2.0.7

    sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 31 12:44:42 2010
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Enter user-name: / as sysdba
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> desc user$
    Name                            Null?    Type
    USER#                            NOT NULL NUMBER
    NAME                            NOT NULL VARCHAR2(30)
    TYPE#                            NOT NULL NUMBER
    PASSWORD                             VARCHAR2(30)
    DATATS#                       NOT NULL NUMBER
    TEMPTS#                       NOT NULL NUMBER
    CTIME                            NOT NULL DATE
    PTIME                                  DATE
    EXPTIME                             DATE
    LTIME                                  DATE
    RESOURCE$                       NOT NULL NUMBER
    AUDIT$                              VARCHAR2(38)
    DEFROLE                       NOT NULL NUMBER
    DEFGRP#                             NUMBER
    DEFGRP_SEQ#                             NUMBER
    ASTATUS                       NOT NULL NUMBER
    LCOUNT                        NOT NULL NUMBER
    DEFSCHCLASS                             VARCHAR2(30)
    EXT_USERNAME                             VARCHAR2(4000)
    SPARE1                              NUMBER
    SPARE2                              NUMBER
    SPARE3                              NUMBER
    SPARE4                              VARCHAR2(1000)
    SPARE5                              VARCHAR2(1000)
    SPARE6                              DATE

  • Is there a difference for user agent string for firefox desktop & firefox mobile?

    Is there a difference for user agent string for firefox desktop & firefox mobile?

    Yes. All versions of mobile Firefox have "Fennec" in the useragent string. For example:
    Mozilla/5.0 (Android; Linux armv7l; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1
    For more details and examples, please see this article:
    http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/

Maybe you are looking for

  • List-Items (Type=URL) - how to open in New Window

    I use a List for deliver information in a region. The list consist of some URLs. I would like to open a new Window (not use the active Window), if one element was clicked. With html-text-region I could user "target=...", but this is not usable in the

  • EMI 2/6, 6/2 etc. Anyone using these?

    I'm ready to upgrade to Logic Studio and would like to know if the old Emi 2/6 (A 2/6) or 6/2 usb interfaces will work in Leopard with Logic Studio (or Express/Garageband) Thanks

  • WRT160N as Access point

    Hey all, The library 2 buildings away (my house, neighbors house, library) has free public wifi. They have a 3com N wireless router. I can only get a signal if I build a cantenna. Now, I am looking to take that signal and enhance it so all wireless c

  • How to get status of an rs232 connection

    Hi, I am trying to read out the status of on RS232 connection. How can I do this? Moreover would it be great to make the handshake visible! Is there a way that I can do that? I would like to make a program something like where I can push a button "co

  • What is the best way to cleanup my iMac 10.7.5?

    I have tons of space - this is not the issue. My computer has slowed down significantly and I thought a cleanup may help.  Also, I renetly recieved an e-mail from someone I know and it was sent by a third party who hacked this friends e-mail.  In add