• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get the original value of a system property?  RSS feed

 
Patrick Maloney
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to find out if there is a way to determine what the original value of 'java.awt.printerjob' was (if a user changes it on the command line). This is the class that is returned by PrinterJob.getPrinterJob(). It varies by platform.

How does the JRE set this value anyway? I search far and wide for a properties file that contains platform-specific system properties and could find anything.
Regards, Patrick
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System properties can be set to default values by the JRE, or they can be set on the command line by the "java" command, or they can be modified by user code (System.setProperty and System.clearProperty). There is no way for you to tell which of these things has happened after they happen.
 
Patrick Maloney
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am interested in 'java.awt.printerjob', specifically. While there isn't a System.getOriginalSystemProperty() method, your statement isn't accurate. I can look at 'os.name' and know what it should be, at least for the current version of 1.6 on Windows, OSX, and Linux as I have access to those platforms and can see what it is by default. Hard-coding those class names in a check isn't very clean.

However, to future-proof my check and make sure it works on platforms I do not have access to, I need a way, direct or indirect, to figure out what the original value was of 'java.awt.printerjob'.

Is there a way to look at a Class with reflection and tell if it came with the JRE (signed in some way)?

I basically need to be able to determine if the class specified by 'java.awt.printerjob' was created by a user.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patrick Maloney wrote:I basically need to be able to determine if the class specified by 'java.awt.printerjob' was created by a user.


Ah well, that's an entirely different question. If the name of a class starts with "java." or "javax." or "com.sun." then it's a standard API class. (I believe that's the full list, but the Java Language Specification should be more precise.) Users can't create classes in these packages.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!