Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get system specific information?????

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
Hi,
I want to get information such as the screen resolution of the machine running my java app, and other things, such as default desktop colour and other miscellaneous things...
How would I go about this in Java? I can't find anything in the System class, and any other classes I can think of.

Any and all comments are very welcome!
Cheers every1,
Oxy we are all of us living in the gutter.
But some of us are looking at the stars.
 
Code:
java.awt.DisplayMode dm = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDisplayMode();

System.out.println("Screen width: " + dm.getWidth() + " height: " + dm.getHeight);

does that help?
-pete
 
I use,

java.util.Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

 
I can't test this, but does palbano's method work better on remote machines, i.e. where the application is running on a server, but the screens are being displayed to a local display?

I'm guessing that Toolkit.getDefaultToolkit().getScreenSize() might return the screen dimensions of the machine running the code, not the destination of Graphics2D drawing methods, so may not be suitable/portabl to different client displays.
 
>> work better on remote machines, i.e. where the
>> application is running on a server, but the screens
>> are being displayed to a local display?

What environment are you working with Droplets? It’s the only Java based thin client technology I am aware of.

To answer you question, I have no idea since I don’t know anything about Droplets or whatever thin client technology your working with.

-pete
 
No I'm not using droplets, but I have developed on UNIX boxes, where it is very easy to run an application (could be Java, C++ C etc..) on a server, but direct display outputs to a different machine. The server may have a screen resolution of 1200x1000, whereas the users display my be 1600x1200.. for example. This is sometimes useful if the server has the data/speed necessary to run the application. So when running the Java code, which "dimension" would the above calls provide.

It's just a passing thought, as currently it's not an issue to me ;-)
 
The mechanism your using has nothing to do with Java yes? So unless it somehow provides that information to the Java runtime, the runtime cannot possibly know about system information where the VM is not running.

-pete
 
The UNIX OS makes graphics calls to the windows manager onto which the "frames" will appear. It is not unreasonable to assume that it might therefore know the screen resolution, fonts available, color tables etc. I don't know whether it does or not.
 
thekobbler,

I hate to make assumptions. That said, i agree that it seems very likely in that environment the data would be available to the VM. If you ever verify that could you post your findings here? That would be great to know.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top