Skip to main content
12-Amethyst
Feb 13, 2025 1:17 PM UTC
Solved

Getting java.util.MissingResourceException on function java.util.ResourceBundle.getBundle

I recently solved a problem I had in J-Link that could be of interest to others.

I wanted to use a library as part of my J-Link program. The library is org.netbeans.swing.outline . My program uses somewhere deep down the class ETable, which has an initialization that uses a resourcebundle for localization.

 

Specifically it sets up a field for a sting that directly loads a resource Bundle.properties.

private String selectVisibleColumnsLabel =
java.util.ResourceBundle.getBundle("org/netbeans/swing/etable/Bundle").getString("LBL_SelectVisibleColumns");

 

At first this gave me an error,

java.util.MissingResourceException

because it could not find the resource.

 

The library itself loaded fine, as I have been repackaging my jar to include all libraries. (Not the best practice, but easier than adding many libraries to the protk.dat)

 

Using Creo 8.0.8.0 and Java 11.

RoDesAnswer
12-Amethyst
Feb 13, 2025 1:18 PM UTC

The problem and solution were in the classpath for my application.

Article CS309245 (https://www.ptc.com/en/support/article/CS000309245) lists 3 ways to set up a classpath.

    1. Creating the CLASSPATH environment variable either:
      1. Hardcoded in Windows : valid for the whole Windows session
      2. With a custom script (batch file) or appended to the parametric.bat file : valid solely for the current Creo session
  1. Setting the config option add_java_class_path : valid solely for the current Creo session
  2. In the .dat file using the keyword java_app_classpath : valid solely when the application is registered

I was using option 3 so far, with all my libraries and my program repackaged into a single jar.

I had to use option 2, to get this bundle to load, and to resolve my problem.

In my config.pro I added a line with keyword add_java_class_path and as value, the location of that library.

While using option 3, my classpath did not show the library. With option 2, my classpath does show the added library.

 

I hope this can help others.

1 reply

RoDes12-AmethystAuthorAnswer
12-Amethyst
Feb 13, 2025 1:18 PM UTC

The problem and solution were in the classpath for my application.

Article CS309245 (https://www.ptc.com/en/support/article/CS000309245) lists 3 ways to set up a classpath.

    1. Creating the CLASSPATH environment variable either:
      1. Hardcoded in Windows : valid for the whole Windows session
      2. With a custom script (batch file) or appended to the parametric.bat file : valid solely for the current Creo session
  1. Setting the config option add_java_class_path : valid solely for the current Creo session
  2. In the .dat file using the keyword java_app_classpath : valid solely when the application is registered

I was using option 3 so far, with all my libraries and my program repackaged into a single jar.

I had to use option 2, to get this bundle to load, and to resolve my problem.

In my config.pro I added a line with keyword add_java_class_path and as value, the location of that library.

While using option 3, my classpath did not show the library. With option 2, my classpath does show the added library.

 

I hope this can help others.

Translate