Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java Language
Expertise: Beginner
Mar 20, 1997

Using Java to Control System Functions

I would like to be able to browse my server and have an applet/program that would mimic the functions of, say, the control panel on a Macintosh. Would I need to write a custom browser to be able to do this?

Also, I would like to be able to have the server check the version of the browser and suggest to the user, "Do you want to update your browser?" If they click "Yes," have the new browser download and install.

Java is probably not the right tool for doing this.

Creating a control panel like that on the Macintosh requires that your program have intimate knowledge of the operating system and hardware it is running on. Things like the audio volume level, number of colors on the screen, screen saver settings, speed of the CPU, battery saving features, and so on, are so tied to the operating system and the vendor of the hardware, that Java cannot possibly provide enough hooks for you to be able to accomplish them all in Java.

Indeed, Java is meant to be used as a cross-platform language that provides a uniform, easy to access programming interface to the multitude of environments in use today. The point is that applications can be written once and run everywhere equally well. Putting in platform-specific dependencies takes away much of the advantages of programming in Java in the first place. Moreover, Java applets are restricted even further in what they can do. This feature is what makes Java a secure programming language for the Web. An applet would never be allowed to read or configure a system's settings, for example, because these could be exploited by malicious applets.

The only system settings an applet would be able to read are those accessible via the System.getProperties() call. This method takes a string parameter describing the property in question. Properties are divided into two categories: hidden and non-hidden ones. Hidden ones cannot be read by applets by default.

The list is as follows:

Non-hidden Properties  Description
java.version           Java version number
java.vendor            Java-vendor-specific string
java.vendor.url        Java vendor URL
java.class.path        Java classpath
os.name                Operating system name
os.arch                Operating system architecture
os.version             Operating system version
file.separator                 File separator ("/" on Unix)
path.separator                 Path separator (":" on Unix)
line.separator                 Line separator ("\n" on Unix)

Hidden Properties      Description
user.name              User account name
user.home              User home directory
user.dir               User's current working directory
java.home              Java installation directory
java.class.version     Java class format version number
As you can see, this list is much too limited to allow you to do sophisticated things, but one thing you'll notice is that an applet can get the version of the operating system and the browser if that information is carried in the java.vendor property. The applet can then notify the user that his/her browser is out of date and suggest that he/she download a newer version.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date