Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Strange settings in System.getProperties

  1. #1
    Junior Member
    Join Date
    Sep 2021
    Location
    Midwest US
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Strange settings in System.getProperties

    I've just started learning Java. I have installed Oracle's Java 16 on my OpenSuSE desktop machine, and I wrote this little program to display System properties:
      import java.io.Console;
     
      public class ShowSystem
       {public static void main(String[] args)
         {Console console = System.console();
          String path_separator  = System.getProperty("file.separator");
          String file_separator  = System.getProperty("java.class.path");
          String line_separator  = System.getProperty("java.home");
          String java_class_path = System.getProperty("java.vendor");
          String java_home       = System.getProperty("java.vendor.url");
          String java_vendor     = System.getProperty("java.version");
          String java_vendor_url = System.getProperty("line.separator");
          String java_version    = System.getProperty("os.arch");
          String os_arch         = System.getProperty("os.name");
          String os_name         = System.getProperty("os.version");
          String os_version      = System.getProperty("path.separator");
          String user_dir        = System.getProperty("user.dir");
          String user_home       = System.getProperty("user.home");
          String user_name       = System.getProperty("user.name");
          console.format(" Path separator = %s%n",   path_separator);
          console.format(" File separator = %s%n",   file_separator);
          console.format(" Line separator = %s%n%n", line_separator);
          console.format("Java class path = %s%n",   java_class_path);
          console.format("Java       home = %s%n",   java_home);
          console.format("Java     vendor = %s%n",   java_vendor);
          console.format("Java vendor url = %s%n",   java_vendor_url);
          console.format("Java    version = %s%n%n", java_version);
          console.format("Os architecture = %s%n",   os_arch);
          console.format("Os         name = %s%n",   os_name);
          console.format("Os      version = %s%n%n", os_version);
          console.format("User  directory = %s%n",   user_dir);
          console.format("User       home = %s%n",   user_home);
          console.format("User       name = %s%n",   user_name);
         }
       }

    It shows some bizarre settings for file.separator and line.separator, that I think are attributable to the path.separator property:
    $ java ShowSystem
     Path separator = /
     File separator = .:/home/leslie/bin/NetRexx/:/usr/java/jdk-16.0.1/bin/java:/usr/local/NetRexx/lib/NetRexxF.jar
     Line separator = /usr/java/jdk-16.0.1
     
    Java class path = Oracle Corporation
    Java       home = https://java.oracle.com/
    Java     vendor = 16.0.1
    Java vendor url =
     
    Java    version = amd64
     
    Os architecture = Linux
    Os         name = 5.3.18-59.19-default
    Os      version = :
     
    User  directory = /home/leslie/Documents/SourceCode/Languages/Java/Tutorials
    User       home = /home/leslie
    User       name = leslie

    Actually, looking at the output again, quite a few of these values (java.*, os.*) seem suspect as well. :-)

    Is this something I can correct myself, or does Oracle need to do it?

    Leslie

    --- Update ---

    Hmmm... but it looks like maybe version 16 has replaced System.getProperty() with getSystemProperties() in java.lang.management? (At least, that's what Oracle's search page pointed me to.)
    Last edited by jlturriff; September 21st, 2021 at 10:13 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Strange settings in System.getProperties

    settings for file.separator
    Check that the getProperty() call matches the variable that the returned value is stored in. For example:
     String file_separator  = System.getProperty("java.class.path");
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2021
    Location
    Midwest US
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Strange settings in System.getProperties

    Boy, am I embarrassed.

Similar Threads

  1. Simple game that requires me to load game settings from a file
    By 14fenix in forum Java Theory & Questions
    Replies: 5
    Last Post: December 1st, 2011, 09:21 PM
  2. Database settings (username and password)
    By palooza in forum JDBC & Databases
    Replies: 3
    Last Post: February 24th, 2011, 01:53 AM
  3. Replies: 0
    Last Post: January 17th, 2011, 05:14 AM
  4. How and where do you save user settings?
    By snytkine in forum AWT / Java Swing
    Replies: 3
    Last Post: October 12th, 2010, 05:46 AM
  5. get proxy settings from the default system browser
    By reguapo in forum Java Networking
    Replies: 0
    Last Post: January 15th, 2010, 08:43 AM