File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic

problem finding resouircebundle?

 
Darren Briaris
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 884
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Try putting the properties file into your JAR.
 
Darren Briaris
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Darren Briaris
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Discussion continued here
 
    Bookmark Topic Watch Topic
  • New Topic