You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Jeff Schmidt <js...@weldingengineering.com> on 2021/01/01 14:28:40 UTC

Netbeans/Maven Resource Bundle problem (classpath?)

Hello,

   I'm very new to both Java programming in general, and NetBeans 
specifically. Have used Eclipse a little bit at work, but trying out 
NetBeans - in part because I'm working through the Java Tutorials on the 
Oracle site, and specifically, trying to work through the section on 
Swing GUI programming, which is heavily based on NetBeans (an old 
version, but, the current version is sufficiently similar to still work 
through the tutorial).

   For some reason, I got it in my head after getting the 
CelsiusConverter tutorial project created and working, to run NetBeans's 
Internationalization Wizard to internationalize the project (ie move 
string constants out to a Resource Bundle, replacing the string 
constants with lookups from the locale bundle).

   Since running the I18N Wizard, when I try to run the app, I now get 
Maven exceptions about not being able to find the resource bundle. I 
suspect this is some sort of classpath issue with Maven. The I18N Wizard 
helped me create an initial default/base resource bundle. When I started 
getting the error, I found an option in a right-click menu to add a new 
locale, so I added en_US, to see if that would resolve the error, but 
that didn't make any difference.

Error and project screenshot below:



Does anyone have suggestions for how to fix this? Do I need to modify 
pom.xml somehow to make it aware of the Resource Bundles?


Re: Netbeans/Maven Resource Bundle problem (classpath?)

Posted by Jeff Schmidt <js...@weldingengineering.com>.
Thanks. Manually creating that structure and moving the files did get it 
working. Still, it feels like NetBeans could do more to support this and 
make it work automatically.


On 1/1/21 10:48 AM, Ernie Rael wrote:
>
> On 1/1/2021 6:28 AM, Jeff Schmidt wrote:
>>
>> Hello,
>>
>> ...
>>
>>   For some reason, I got it in my head after getting the 
>> CelsiusConverter tutorial project created and working,
>>
>
> It can be fun to play
>
>
>> to run NetBeans's Internationalization Wizard to internationalize the 
>> project (ie move string constants out to a Resource Bundle, replacing 
>> the string constants with lookups from the locale bundle).
>>
> Maven keeps resources in a "mirror" directory structure. For example, 
> you should see
>
>    Other Sources
>
> at the same level as
>
>    Source Packages
>
> with an underlying directory structure like
>
>    src/main/java
>    src/main/resources
>
> If it's missing, I know of no way to ask NetBeans to create it. 
> NetBeans should have a
>
>    Move to Resources
>
> action to help with all the legacy stuff that doesn't know about the 
> maven structure. But I don't think there is such a thing.
>
> AFAICT, you will have to manually move the files to the correct 
> location. Note that the full structure is mirrored. In your example 
> you have the bundle under the learn package. Thing are automatically 
> copies to their corresponding place when the jar file is created. You 
> probably want something like
>
>    src/main/resources/learn/xxxBundle.properties
>
> Looks like a bug in the internationalization wizard.
>
> This causes no end of problems for those unfamiliar with this. You 
> probably have to manually move the files over Some searching about 
> maven project directory structure may be of assistance.
>
> -ernie
>
>>   Since running the I18N Wizard, when I try to run the app, I now get 
>> Maven exceptions about not being able to find the resource bundle. I 
>> suspect this is some sort of classpath issue with Maven. The I18N 
>> Wizard helped me create an initial default/base resource bundle. When 
>> I started getting the error, I found an option in a right-click menu 
>> to add a new locale, so I added en_US, to see if that would resolve 
>> the error, but that didn't make any difference.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: Netbeans/Maven Resource Bundle problem (classpath?)

Posted by Ernie Rael <er...@raelity.com>.
On 1/1/2021 6:28 AM, Jeff Schmidt wrote:
>
> Hello,
>
> ...
>
>   For some reason, I got it in my head after getting the 
> CelsiusConverter tutorial project created and working,
>

It can be fun to play


> to run NetBeans's Internationalization Wizard to internationalize the 
> project (ie move string constants out to a Resource Bundle, replacing 
> the string constants with lookups from the locale bundle).
>
Maven keeps resources in a "mirror" directory structure. For example, 
you should see

    Other Sources

at the same level as

    Source Packages

with an underlying directory structure like

    src/main/java
    src/main/resources

If it's missing, I know of no way to ask NetBeans to create it. NetBeans 
should have a

    Move to Resources

action to help with all the legacy stuff that doesn't know about the 
maven structure. But I don't think there is such a thing.

AFAICT, you will have to manually move the files to the correct 
location. Note that the full structure is mirrored. In your example you 
have the bundle under the learn package. Thing are automatically copies 
to their corresponding place when the jar file is created. You probably 
want something like

    src/main/resources/learn/xxxBundle.properties

Looks like a bug in the internationalization wizard.

This causes no end of problems for those unfamiliar with this. You 
probably have to manually move the files over Some searching about maven 
project directory structure may be of assistance.

-ernie

>   Since running the I18N Wizard, when I try to run the app, I now get 
> Maven exceptions about not being able to find the resource bundle. I 
> suspect this is some sort of classpath issue with Maven. The I18N 
> Wizard helped me create an initial default/base resource bundle. When 
> I started getting the error, I found an option in a right-click menu 
> to add a new locale, so I added en_US, to see if that would resolve 
> the error, but that didn't make any difference.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists