Results 1 to 9 of 9
Like Tree2Likes
  • 2 Post By jim829

Thread: System Resource Enumeration

  1. #1
    Jonesy29847 is offline Member
    Join Date
    Jul 2015
    Location
    Michigan
    Posts
    4
    Rep Power
    0

    Default System Resource Enumeration

    Hello, New to Java trying to rewrite an application from C, I now longer have the source, and I wonder which package to import to enumerate system resources.

    Thanks in advance.

  2. #2
    Xen
    Xen is offline Member
    Join Date
    Jan 2015
    Posts
    86
    Rep Power
    0

    Default Re: System Resource Enumeration

    There is a class called java.lang.System but I am not sure what you can do with it. However, this method looks interesting:

    System.getproperties()
    Last edited by Xen; 07-26-2015 at 03:01 PM.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: System Resource Enumeration

    Can you list some of the system properties that you are interested in?
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    Jonesy29847 is offline Member
    Join Date
    Jul 2015
    Location
    Michigan
    Posts
    4
    Rep Power
    0

    Default Re: System Resource Enumeration

    USB ports, and printers for now.
    Thanks

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: System Resource Enumeration

    I don't know if java has any classes/methods to get that info directly.
    You probably have to call an OS command and parse its response.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: System Resource Enumeration

    For printers.

    Java Code:
          ObservableSet<Printer> printers = Printer.getAllPrinters();
          for (Printer p : printers) {
             System.out.println(p);
          }
    Regards,
    Jim
    Norm and DarrylBurke like this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: System Resource Enumeration

    Ah, that's in JavaFX which I haven't looked at much.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: System Resource Enumeration

    Java is not designed for doing something as operating system specific as enumerating system resources, so you'll have to resort to third party projects:

    usb4java - About
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: System Resource Enumeration

    Quote Originally Posted by Norm View Post
    Ah, that's in JavaFX which I haven't looked at much.
    That's funny since I had no idea it was JavaFX until your post. I knew I had done this a couple of years ago so I just starting typing print in Eclipse (which in it's infinite wisdom, directed me to the above solution). Quite fortuitous actually. Here is the non-JavaFX version.

    Java Code:
    PrintService[] ps = PrinterJob.lookupPrintServices();
    for (PrintService p : ps) {
        System.out.println(p);
    }
    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 3
    Last Post: 09-23-2013, 04:55 PM
  2. StringArray Enumeration
    By loopsnhoops in forum New To Java
    Replies: 1
    Last Post: 06-01-2011, 06:30 PM
  3. nxn 0-1 array enumeration
    By hollygrove in forum Advanced Java
    Replies: 3
    Last Post: 10-16-2009, 09:33 AM
  4. Enumeration
    By kishan in forum Advanced Java
    Replies: 3
    Last Post: 06-19-2009, 12:27 AM
  5. Declaring Enumeration
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-04-2007, 05:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •