This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Native gcj: --resource does not work
- From: Jens Fransson <fransson at fransson dot de>
- To: melko at gmx dot at
- Cc: java at gcc dot gnu dot org
- Date: Tue, 4 Jan 2005 19:33:22 +0100
- Subject: Re: Native gcj: --resource does not work
- Organization: Fransson Software
- References: <1856737638.20050103201334@fransson.de><13683.1104824593@www70.gmx.net>
- Reply-to: Jens Fransson <fransson at fransson dot de>
Hi Melko!
on Tuesday, 4. January 2005 at 08:43 you wrote:
mga> Yes I load the property file with ResourceBundle.getBundle() and it looks
mga> like this:
mga> resJTalk = ResourceBundle.getBundle("resources/jtalk_deutsch");
mga> So it loads the file jtalk_deutsch.properties !! And that it's what you
mga> want?
This reveals the problem: according to the Java documentation of
the ResourceBundle class, the above call should be written as
ResourceBundle.getBundle("resources.jtalk_deutsch");
to access the properties file (note the "." instead of the "/").
The JavaDoc states that your call is also supported, but rather
for compatibility reasons.
So there is an inconsistency between Sun's ResourceBundle and GCJ's
one. Good to know. Perhaps I should stick with good old Sun's Java.
(Apart from compatibility issues, my current app is about 400% faster
with Sun's JRE than with GCJ...)
ResourceBundle documentation:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader)
mga> But I have also a problem with Class.forName() searching, because it cannot
mga> find the database-libraries in jar-format and if you have experience with it
mga> I would ask you some questions!
I have to admit that I am a newbie to GCJ so you will likely get
better help when you send your questions to the experts on the GCJ
mailing list (java@gcc.gnu.org).
mga> Have a nice day!
mga> PS: If you want we can talk in german! :-)
Usually I prefer German, but as our contact evolved from GCJ's mailing
list, we make sure that the others can read our ideas as well by using
English.
Cheers,
Jens
>> Hello,
>>
>> thanks for your reply!
>>
>> Your technique only works with class-files, which is not a real
>> problem, although I heard that gcj produces better output when working
>> on plain source code.
>>
>> Your mail does not say anything about wether you tried to load a
>> .properties file via the ResourceBundle.getBundle() method. This did
>> not work for me, but it seems to me that this is rather a problem with the
>> implementation of ResourceBundle.java than with the "--resource"
>> switch of gcj. I suspect this because I was able to create a
>> workaround using ClassLoader.getSystemResource() which finds the
>> .properties file.
>>
>> Did you try the ResourceBundle.getBundle() method?
>>
>> Nice greetings from Germany/Hamburg,
>> Jens
>>
>> on Monday, 3. January 2005 at 15:18 you wrote:
>>
>> mga> You need no --resource to load the RessourceBundle! You should only
>> put it
>> mga> into the jar file and then make out of the jar file the exe-file!!
>>
>> mga> Looks like this:
>>
>> mga> mkdir bin
>> mga> cd bin
>> mga> mkdir resources
>> mga> cd ..
>> mga> mkdir obj
>> mga> mkdir include
>>
>> mga> xcopy /Q src\resources\*.* .\bin\resources
>> mga> cd bin
>> mga> jar cf %MAIN%.jar com\test\gui\*.class com\test\gui\dialog\*.class
>> mga> com\test\gui\functions\*.class resources\*.*
>> mga> cd ..
>>
>> mga> make the object-file out of jar:
>>
>> mga> gcj --classpath=obj;bin; -fjni -g0 -Os -c include\%MAIN%.jar -o
>> obj\%MAIN%.o
>>
>> mga> make the library with out of jar:
>>
>> mga> cd obj
>> mga> ar -crs lib%MAIN%.a *.o
>> mga> move lib%MAIN%.a ..\include
>> mga> cd ..
>>
>> mga> make the exe:
>>
>> mga> gcj -mwindows --main=com.test.gui.%MAIN% -fjni -g0 -Os -s -o
>> %MAIN%.exe
>> mga> obj\*.o include\*.a
>>
>> mga> and it works fine!!
>>
>> mga> nice greetings from austria.
>>