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 ;)

Similar Messages

  • 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") 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.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 :)

  • 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("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.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

  • 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.

  • 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 Properties user.timzone different between dev. and prod. system

    Hi all,
    I am facing the following issue:
    In our development system I get in http://<server:port>/sap/monitoring/SystemProperties -> dispatcher -> system properties a Europe/Berlin for user.timezone.
    In our productive system I get in http://<server:port>/sap/monitoring/SystemProperties -> dispatcher -> system properties a GMT for user.timezone.
    Can anybody explain which system property is requested by the J2EE-engine when calling this property?
    I ask, because I wrote a small programm requesting the user.property via java (expecting j2ee-engine would do that too) an got back an empty string (on both systems).
    So, how/where can I change the parameter, so that the development system uses GMT, too?
    I already checked the spro settings in sap, they are identical. System -> status showes the same for both systems, too.
    I hope for your help.
    Thanks and regards
    Christian

    Hello Chris,
    I checked the system variables with TA SM51 ->goto -> server -> information -> environment.
    There is nothing like the TZ variable on both systems (we use Linux).
    Do you have an other idea?
    How can I change the user.timezone shown in Java system properties?
    Regards
    Christian

  • User.dir

    Hi All !
    i want to get currnet sytem directory in my code by
    System.getProperty("user.dir");in my ide enviroment it is working properly but when i build executable .jar file
    it returns active jre directory how can i get executable .jar file directory in my code when build it to .jar file?
    thanks

    Yes ...It is possible.
    Just open the Server start Script (<DOMAIN_HOME>\bin\startWebLogic.cmd) and then set the following JAVA_OPTION There like :
    <font color=maroon> In WINDOWS based OS (startWebLogic.cmd) Code Snippet</font><BR>
    set DOMAIN_HOME=C:\bea103\user_projects\domains\base_domain
    for %%i in ("%DOMAIN_HOME%") do set DOMAIN_HOME=%%~fsi
    call "%DOMAIN_HOME%\bin\setDomainEnv.cmd" %*
    set SAVE_JAVA_OPTIONS=%JAVA_OPTIONS%    <b> -Duser.dir=E:/MyDirectory </b>
    <font color=maroon> In UNIX based OS (startWebLogic.sh) Code Snippet</font><BR>
    DOMAIN_HOME="/opt/app/bea103/user_projects/domains/base_domain"
    . ${DOMAIN_HOME}/bin/setDomainEnv.sh $*
    SAVE_JAVA_OPTIONS="${JAVA_OPTIONS}"    <b> -Duser.dir=/opt/app/MyDirectory </b>
    If you are starting your Servers from AdminConsole with the Help of NodeManagers then you can set the JAVA_OPTIONS like mentioned in the below Link:
    http://jaysensharma.wordpress.com/2010/03/26/nodemanager-based-managedservers-setting-mem_args/

  • Applet = PropertyPermission user.dir read

    Have applet with package name of FileSave.
    Running JBuilder5 and have no problems....
    Complied no problems....
    But when I put the classes and html in a directory other than jbuilder directory I get
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
    Getting directory by:
    String curDir = System.getProperty("user.dir");Also tried:
    String curDir = new File(".").getAbsolutePath();  //File dir from Jbuilder project directory
    String fileDir = curDir.substring(0,curDir.length()-1); // Remove last "." from directoryTried setting permissions but NO SUCCESS !!!
    FilePermission p = new FilePermission("C:\\Kyle\\Java\\FileSave\\userdata.txt", "read");
    FilePermission p1 = new FilePermission("user.dir", "read");
    Any Ideas ???
    html applet is
    <applet
    code = "pwise.class"
    hspace = "0"
    vspace = "0"
    align = "top"
    width = 512
    height = 384
    >
    Kyle

    I have a similar problem. I wrote a signed applet that shows a file chooser to select the files to be processed and uploaded. With jre 1.4.0.2 I had no problem. With jre 1.4.2.05 an exception is thrown when the file chooser tries to retrieve the user.dir property.
    I tried to grant all permission to the applet launching the java plug-in with a particular security policy
    grant codeBase "my codebase" {
    permission java.security.AllPermission;
    So the system doesn't ask me if I accept the applet certificate and grants me permission to write file to disk
    but still the exception is thrown when the file chooser tries to retrieve the user.dir property.
    Any suggestion?

  • How do I setup the "user.dir"?

    Hello,
    Is there a way to have the real "user.dir" with Forte:
    printing : System.getProperty("user.dir")
    I get ---> C:\forte4j\bin
    executing with command line : --->C:\MyProjectRoot
    thanks in advance for the tips
    laurent

    It looks like you might be running your application from the IDE. In that case, the user.dir property gets set to whatever directory you were in when you started the IDE.
    You could either:
    * Start the IDE in the directory to which you would like the user.dir property set
    * Call System.setProperty("user.dir", "C:\MyProjectRoot") at the beginning of your application
    * Set up a .properties file for your application

  • Get current directory(without user.dir)!!!!

    Dudes,
    need help badly... i need to get the current directory of the jar file where it gets launched from. Since the launching takes place from an html file, the system property "user.dir" does not get set to the current directory. Both the html as well as the jar file is in the same location.
    so in short, i need to get the current dir without using the user.dir that i can later set it explicitly thru my program(to the current dir)

    "Search the CLASSPATH for the first occurence of your jar file... but FFS only do it once, and save the result"
    Cud ya elaborate that statement.
    Also, the reason i wanna know is this : my jar file references all the images that it uses, thru a relative path(./a/b/c.....). So wen i simply double click the jar file, the relative path("./") gets replaced with the current workin directory(from user.dir) and fetching of images works perfectly. But if it is launched via html, the user.dir does not get set to the current working dirctory and as a result the jar file looks for its images in the default location which is the desktop. so it doesnt work
    Now that the context is clear, is there a way out???? or is there any way in which i can set the user.dir from the html itself(maybe by using javascript or somethin??)

Maybe you are looking for

  • Will download message from my MY POP ACCOUNT BUT STOPPED DOWNLOADING FROM IMAP ACCOUNT ON THE SAME SERVER

    Hi, IMAP (from gmail stopped) working few days ago but just on my PC (running Windows 7). I can still send email, but I can't receive emails on gmail and Thunderbird doesn't want to copy the message to Sent Mail folder after sending it. Thunderbird w

  • My ipod Shuffle is Dead?

    I have a Ipod Shuffle since November 25, it worked very well until yesterday, i dont know what happenned, but it wont turn on, and my computer wont recognise it, only sometimes after plugging it several times it starts charging, but it gets very hot

  • Start-up issues - system folder

    Hey gang, I've got a bondi blue 233mhz G3 iMac. It has 160 mg of ram if I remember right (has 128mb chip in slot). Anyways, I got a hard drive from the guts of another imac we found... in a dumpster, of all places. The motherboard was fried on that o

  • ALe Error 29

    Hi, I am trying send Message type PICKSD, I am getting error 29 error in ALE service layer. My partner profile sounds ok. Can Anyone please tell me the possible reason. Thanks, Santosh

  • How to show and enable wireless devices

    Hi, I've reinstalled arch on my Acer Aspire One..During the installation I didn't checked all the packages...Only a few which I use oftenly...Maybe I missed something? Esp. the wireless...:( I've already installed wireless-tools and added ath5k on my