cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

JLink Static Utility Classes

BrianKrieger
7-Bedrock

JLink Static Utility Classes

Hello again, all!

So I'm trying to be smarter about my utility classes (properties, loggers, etc.). I may not be understanding this correctly and may be making a horrible mistake, so any corrections/concerns/comments would be most appreciated.

I have my startup class (called out in creotk.dat). It, in turn, instantiates a class with static values/methods/etc.

public static void start(){

//The properties are used throughout the other JLink stuff.
new com.paccar.commonUtils.GenerateProperties();
........


The generateproperties class has (among other things) static Properties (with a getter/setter)

public class GenerateProperties {

private static Properties jlinkProps = new Properties();

public GenerateProperties(){

jlinkProps.put("tmpFileLocation",System.getenv("TEMP"));

..........

public static Properties getJlinkProps(){
return jlinkProps;
}


I then have another startup class that is instantiated in the same creotk.dat file. I was attempting to access the static values of the properties file in this file. They come up null.

JOptionPane.showMessageDialog(null, com.paccar.commonUtils.GenerateProperties.getJlinkProps().getProperty("draFileLocation"));

So, am I completely misunderstanding the use of static values/methods? If the values are initially set right away, no problem (i.e. if I access a static String already initialized to something at the beginning of the class, no sweat).

BK




0 REPLIES 0