aspose file tools*
The moose likes Beginning Java and the fly likes problem finding resouircebundle? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

problem finding resouircebundle?

Darren Briaris
Greenhorn

Joined: Jul 19, 2006
Posts: 15
I have a java program packaged into a jar file. There is also a properties file I wish to distribute with the jar file (but not in the jar file). When I run the program it cannot find the resourcebundle. I get the error :-

Caused by: java.util.MissingResourceException: Can't find bundle for base name c
om.das.comp.stuff.messages, locale en_GB

The jar file is in a directory on my local machine (say c:\whatever) and I am running the jar file from within that directory. Where should I put the properties file so it can be found?? I have pointed the classpath to include the C:\whatever directory and it still does not work.

Any help greatly appreciated!
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Try putting the properties file into your JAR.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Darren Briaris
Greenhorn

Joined: Jul 19, 2006
Posts: 15
Originally posted by Chengwei Lee:
Try putting the properties file into your JAR.


That does work but I wanted the properties file available outside the jar so it can be changed without changing the jar file.

I assume this is possible?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14432
    
  23

How are you running the jar? By using java -jar myjarfile.jar?

When you run a JAR file like that, the CLASSPATH environment variable or the "-classpath" (or "-cp") parameters are not used. The classpath comes from the manifest file in the JAR instead. So it doesn't work to set the CLASSPATH environment variable to "C:\whatever" if you run your JAR with the "-jar" option.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Darren Briaris
Greenhorn

Joined: Jul 19, 2006
Posts: 15
Originally posted by Jesper Young:
How are you running the jar? By using java -jar myjarfile.jar?

When you run a JAR file like that, the CLASSPATH environment variable or the "-classpath" (or "-cp") parameters are not used. The classpath comes from the manifest file in the JAR instead. So it doesn't work to set the CLASSPATH environment variable to "C:\whatever" if you run your JAR with the "-jar" option.


I am running the jar as you outlined above. If I have the manifest file in the jar file I have trouble running the program - "Exception in thread "main" java.lang.NoClassDefFoundError:"

If I have a manifest file in the folder I am running the program from , this seems to work but gives me the error I originally posted.

I think I am just getting myself more and more confused!



My manifest file looks as follows:-

Manifest-Version: 1.0
Main-Class: com.das.stuff.prog.ProgramName
Class-Path: jt400.jar c:/whatever

Is this right? If not what should it be if the jar file is in the "c:\whatever" folder and I am running the program in that folder?

Thanks for the help so far but I am finding this frustrating!
Darren Briaris
Greenhorn

Joined: Jul 19, 2006
Posts: 15
Just an update. I have fixed the "NoClassDef" error when using the maifest file within the jar file by adding the main jar to the manifest classpath entry.

So that is sorted just the properties file causing the problem now..
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
Discussion continued here


Joanne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem finding resouircebundle?