devxlogo

Using Java to Control System Functions

Using Java to Control System Functions

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

Also,I would like to be able to have the server check theversion of the browser and suggest to the user, “Doyou want to update your browser?” If they click”Yes,” have the new browser download and install.

Answer:
Java is probably not the right tool for doing this.

Creatinga control panel like that on the Macintosh requires that yourprogram have intimate knowledge of the operating system andhardware it is running on. Things like the audio volume level,number of colors on the screen, screen saver settings, speed ofthe CPU, battery saving features, and so on, are so tied to theoperating system and the vendor of the hardware, that Java cannotpossibly provide enough hooks for you to be able to accomplishthem all in Java.

Indeed, Java is meant to be used as a cross-platform language thatprovides a uniform, easy to access programming interface to themultitude of environments in use today. The point is thatapplications can be written once and run everywhere equally well.Putting in platform-specific dependencies takes away much of theadvantages of programming in Java in the first place.Moreover, Java applets are restricted even further in what they cando. This feature is what makes Java a secure programming languagefor the Web. An applet would never be allowed to read or configurea system’s settings, for example, because these could be exploitedby malicious applets.

See also  Who are the Modern GPU Cloud Providers?

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

The list is as follows:

Non-hidden Properties  Description——————————————————-java.version           Java version numberjava.vendor            Java-vendor-specific stringjava.vendor.url        Java vendor URLjava.class.path        Java classpathos.name                Operating system nameos.arch                Operating system architectureos.version             Operating system versionfile.separator                 File separator (“/” on Unix)path.separator                 Path separator (“:” on Unix)line.separator                 Line separator (”
” on Unix)Hidden Properties Description——————————————————-user.name User account nameuser.home User home directoryuser.dir User’s current working directoryjava.home Java installation directoryjava.class.version Java class format version number
As you can see, this list is much too limited to allow youto do sophisticated things, but one thing you’ll notice isthat an applet can get the version of the operating systemand the browser if that information is carried in thejava.vendor property. The applet can then notify theuser that his/her browser is out of date and suggest thathe/she download a newer version.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist