Localization of app resources in jar

Hi,
I got a problem localizing a Web Start App.
I translated the resources in the property files like javax\swing\plaf\basic\resources\basic.properties as usual to basic_de.properties to support the german local.
All work fine launching the app from command line.
Then I added the new resource property file to my application jar.
But launching the app with Web Start my localized properties in the jar seems to be ignored. I checked the default local in the app (DE_de) but the texts in the Swing dialog now appear again in english.
Any ideas how I can get the translated resource to work?
Thanks in advance for any information.
Regards
Martin Schloeter

one possible guess is
ClassLoader a has access to swing classes
ClassLoader b has access to your app classes, and has a has its parent.
swing classes loaded using b are in fact loaded by a. Now, those classes search for localized resources, they do so using their classloader, that is a. For a, no german localized file exist even though b would have found one.
I do not know if WebStart plays more or less with class loaders, but the exemple I gave can reproduce your problem easily. You did not play for sure with dynamic class loading while running your command line tests.

Similar Messages

  • Resources inside JAR - problem

    I have a strange problem with resources inside JARs.
    I can't load any resource form a JAR file (for example a .property file or .png icon).
    It's not a problem with my progams only. JDBC drivers doesn't work because they cannot find .properties files while they work well when, the driver JAR i uncompressed. It happens every time when some resouces are inside JAR library (classes are loade correctly). The same project runs well on my friend's computer while I've got an error on my computer.
    I tried it on WinXP and Win2003 Server - the same. My java version 1.5.0_06-b05 (but I had the same problem with older versions).
    I figured out that I can find a file inside a JAR, open a stream, load data and everything is OK but data is always 0bytes length. For example using:
    ImageIcon myImageIcon = new ImageIcon(getClass().getResource(pathandfilename));
    I get empty ImageIcons without any error.
    Can anyone help me. Maybe I should find something somwhere in java configuration.
    Message was edited by:
    peper

    But can anyone tell me why my servlet can not access the
    contents inside a jar file?? Any suggestions please?
    Thanks.Without seeing your code, it is likely that you are trying to use file names (like /some/path/yourFileName.ext), not resource names (loadable from the class loader) like /yourFileName.ext.
    Example:
    Instead of:
    FileInputStream stream = new FileInputStream("/some/path/yourFileName.ext");
    do this:
    InputStream stream = getClass().getResourceAsStream("/yourFileName.ext");
    There are other API's which take either a string file name or a URL. You want to go the URL way, where the URL is taken from the classpath as:
    URL url = getClass().getResource("/yourFileName.ext");

  • Loading resources from jar - problem

    I've got a problem when loading resources from jar.
    My code:
    package game.player;
    import javax.swing.ImageIcon;
    import java.awt.Image;
    import game.map.Map;
    import game.map.MapReader;
    import game.emptyclass.EmptyClass;
    import java.net.URL;
    public class Data
        ClassLoader cl = EmptyClass.class.getClassLoader();
        Image image1 = new ImageIcon(cl.getResource("data/sprites/man6.png")).getImage();
        Image image2 = new ImageIcon(cl.getResource("data/sprites/man5.png")).getImage();
        Image image3 = new ImageIcon(cl.getResource("data/sprites/man4.png")).getImage();
        Image image4 = new ImageIcon(cl.getResource("data/sprites/man3.png")).getImage();
        Image image5 = new ImageIcon(cl.getResource("data/sprites/man2.png")).getImage();
        Image image6 = new ImageIcon(cl.getResource("data/sprites/man1.png")).getImage();
        public Image tile1 = new ImageIcon(cl.getResource("data/maps/test/tile1.png")).getImage();
        public Image bg = new ImageIcon(cl.getResource("data/maps/default/bg.png")).getImage();
        public Map map = new MapReader(cl.getResource("data/maps/test/test.map").getPath()).getMap();
        public int getImageWidth()
            return image1.getWidth(null);
        public int getImageHeight()
            return image1.getHeight(null);
    }I get a NullPointerException.
    Thanks in advance!

    Hi ,
    getResource() method argument is not begin with the
    character '/' , ex.
    Image image1 = new
    ImageIcon(cl.getResource("/data/sprites/man6.png")).ge
    tImage();
    I thought of that, but it's not applicable here because getResource is being called on the ClassLoader, not the Class.

  • How can I obtain the resources in jar?

    How can I obtain the resources in jar if the class that to want this resource is static?
    I don't succeed use like:
    getClass().getResourceAsStream("/" + name)
    because my class is static.
    Thaks

    You could do this
    new Object().getClass().getResourceAsStream("/" + name)
    or
    Object.class.getResourceAsStream("/" + name)

  • Google Apps Resource Adaptor?

    Hi,
    Here is a bold question:
    Has anyone implemented a Google Apps resource adaptor?
    Is anyone willing to share it?
    Thanks,
    John I

    anyone?

  • Unable to resolve 'app/ejb/Common.jar#SequenceInstrument'

    I have developed a module with weblogic6.1 , but when I migrate it to weblogic
    7 ,it alway appears errors as following.
    I have build with weblogic 7 for many times , but nothing change , please help
    me.
    ------error info ----
    weblogic.management.ApplicationException: Prepare failed. Task Id = 7
    Module Name: Common, Error: Exception while rollback of module : EJBModule(Common,status=NEW)
    Common.jar; nested exception is:
         javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Common.jar#SequenceInstrument'
    Resolved: 'app/ejb' Unresolved:'Common.jar#SequenceInstrument' ; remaining name
    'Common.jar#SequenceInstrument'
    TargetException: weblogic.ejb20.UnDeploymentException: Common.jar; nested exception
    is:
         javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Common.jar#SequenceInstrument'
    Resolved: 'app/ejb' Unresolved:'Common.jar#SequenceInstrument' ; remaining name
    'Common.jar#SequenceInstrument'
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:661)
         at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:552)
         at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:1056)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:724)
         at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:24)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)

    Hello Sanjay,
    This should work without any problems. Can you provide your manifest.mf file?
    Meanwhile, refer to the following link for more documentation about WebLogic classloading
    and how to specify a manifest.mf file to do what you're trying to achieve:
    http://edocs.bea.com/wls/docs70/programming/classloading.html#1073491
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Sanjay <[email protected]> wrote:
    Hi,
    I have an .ear file which as an ejb.jar and dependent.jar file. Now
    i set the classpath in MANIFEST.MF of ejb.jar and tried to deploy in
    weblogic server7.0 but my ejb is not able to identity my dependent.jar
    its throwing class not found error. I even tried setting up classpath
    even @ my MANIFEST.MF of ear also. still not able to resolve.
    So let me know does dependent.jar in ear is suppoted are not?

  • How do i localize the app name in an air ios app?

    I am trying to compile an adobe air app for iOS with Danish app name? I can get localization to work with eg English, French and German, but not with Danish...
    I put
    <name> <text xml:lang="en"> English </ text> <text xml:lang="da"> and Danish </ text> </name>
    in the app.xml before i compile with the adt, but after compile i can see that only the English name is created in the InfoPlist.strings of the ipa.
    Any ideas on how to achieve a localized app name?

    Helo fideld, officially Adobe Air don't support Danish language. But I may help you.
    1. Download this file https://www.dropbox.com/s/ytx44mxzdgmlfq2/adt.jar
    2. Go to Air SDK\lib\ folder and backup your original adt.jar
    3. Copy my one from step 1
    You may understand that patched adt.jar was produced by me and not by Adobe.
    I just done this for you as a part of community friendly support. It's allow to add "da" language.
    1. Open your *-app.xml
    2. Add lang="da"
    3. Go to supportedLanguages in XML and add "da" also there so it's will be like "en fr de da".
    Patched ADT was made from original latest 4.0.0.1619 and you must use http://labs.adobe.com/downloads/air.html 4.0.0.1619 before apply this patch
    This works well, just tested!

  • Can't get file from resource in jar.

    hi,
    I'm using the folowing mechanism to get a configuration file from my classes jar file.
    URL configUrl = Config.class.getResource("/resources/"+fileName);
    File ressourceFile = new File(configUrl.toURI());while this is working perfectly when i run my app in stand-alone it fails in JavaWebStart. it gives me the folowing error :
    java.lang.IllegalArgumentException: URI is not hierarchical
         at java.io.File.<init>(Unknown Source)
         at line 2 aboveafter some investigation it seems that the first line doesn't return a valid URL. I'm getting something like :
    jar:file:C:/Documents%20and%20Settings/Patrice/Application%20Data/Sun/Java/Deployment/cache/javaws/http/Dfiona/P80/RMface2face.jar!/resources/system.propertiesthe problem (I think) lies in the URL protocol : jar:file:C:/...
    when I run the same lines in stand-alone I get :
    file:/E:/Project/.../classes/resources/system.propertieswhich is just what I want.
    Is there something I am doing wrong?
    thanx,
    Patrice.

    ok thanx.
    in the end I copy the file locally with :
    try{
        InputStream input = Config.class.getResourceAsStream("/resources/"+fileName);
        OutputStream output = new FileOutputStream(userConfigFile);
        byte[] temp = new byte[128];
        while(input.available()>0){
            int nb = input.read(temp);
            output.write(temp,0,nb);
        input.close();
        output.close();
    } catch (IOException e){
    }it works perfectly.
    thx.

  • Classes+resources in JAR: have to add each single Jar file to CLASSPATH?

    Hello,
    For my application, I plan to easily embed plugins that can be added by the user by copying it into a subfolder "plugins".
    Now, I start my app from a shellscript and in order to load resources from within some of these Jars (e.g. using Class.getResourceAsStream() ), it only works if I explicitly add the specific Jar filename to the classpath from the shellscript.
    I read in a German Java book, that also just using folder names is enough, but it does not work for me:
    Works:
    $JAVA_HOME/bin/java -Djava.library.path="./lib" -classpath "./lib:./plugins/test.jar" test.AppFails:
    $JAVA_HOME/bin/java -Djava.library.path="./lib" -classpath "./lib:./plugins/" test.AppIs it really required to add Jars explicitly, so that e.g. my shellscript has to make a Jar listing of that folder in order to pass them as classpath files?
    Thanks and regards,
    Timo

    No, you don't have to do it that way. What you need
    to do is to have your progam create a URLClassLoader
    pointing to all the jars in the plugin directory.
    Then request your plugin classes from that, rather
    than Class.forName();
    You need to create an array of file URLs for the
    jars, use File.listFiles() and then File.toURL() on
    each ..jar you find.
    p.s. If you do it this way make sure your plugin
    classes are not on the classpath.
    Hmm. Cool. I had no idea. Thanks for correcting me.

  • How to get resources from jar-files

    Hi
    in my app I load an image via the Toolkit.getImage() method.
    Works fine if the app and the image are in folders on disk.
    It fails to load the image, if the app (and the image) is packed in a jar file.
    How can I get the image from there?
    I try to get the image as follows:
    String s = getClass().getResource("MyApp.class").getFile();
    AppPath = s.substring(0,s.lastIndexOf("/"));
    String PathToImages = "/images";
    MyImage = (Image)Toolkit.getDefaultToolkit().getImage(AppPath+PathToImages+"/logo32.gif");The App starts and works, it just fails to load the images.
    Any solutions??
    thanx in advance
    Herby

    This is actually pretty easy. First a little background.
    A Jar file is just a Zip file, with a few constructs for Java.
    The getResource() method is used to create a mapping to data within the Jar file, but is actually not necessary after you know how the mapping works.
    Just to give you an example of getResource:
    // returned is a url to the resource you want from your Jar file.
    URL myURL = MyClass.class.getResource("images/myimgage.gif");
    // then you can use this URL to load the resource
    Image img = getImage(myURL);If you were you look at the value of myURL you would see something similar to the followiing.
    jar:http://www.mywebsite.com/mydir/myjarfile.jar!/images/myimage.gifJust to break it down for you.
    The line always starts with the word jar:
    Followed by the path to your jar file.
    A sepearator !/
    Then the file you are loading from the Jar file.
    jar:     path_to_jar_file     !/     path_to_resource_in_jar_fileSo if you'd like, you could just create a URL object, and define the path to the object using the above method rather than using getResource.
    Anyway, back to your code. What I would do is print out what you get for:AppPath+PathToImages+"/logo32.gif"I'm thinking you might be getting 2 "/" in your path because I think:AppPath = s.substring(0,s.lastIndexOf("/"));will leave the "/" at the end and the next line you add the "/" in front of the image directory name. So you my have the following for your image path.mypath//images

  • Resources from JAR files

    This is doubtless very simple stuff, but I nonetheless cannot figure out where I?m going wrong. I just need to open up some image files as icons in my program, and I?m trying to put all of the classes and resources in one jar file. I?m loading the image using getResource, and I have the images in a folder in the same place as my classes. Everything works fine when the files are separate, and the images load successfully. But then I put all the files into a jar (preserving the same hierarchy) and suddenly getResource returns NULL and of course the pictures don?t load. Is there anything else I ought to be doing?
    Many thanks,
    Ned

    Do any other ideas occur to anyone?Clearly there's a mismatch between the path used to reference the images, and the path where they live. This is pretty standard code, I've used it dozens of times, and I'm sure that the other responders have as well. On the surface, what you're doing looks right, so that only leaves one possibility.
    Two, actually: you aren't by any chance running this in an app-server or web-server?
    Assuming you aren't, put some debugging statements in, like this (not compiled, and I can't remember your image paths):
        URL resourceUril = this.getClass().getResource("/some/path/here");
        System.out.println("trying to load image from: " + resourceURL);This will print out a URL in the form jar:/some/path/here. Now display the contents of your jarfile, with jar tvf JARFILE. You'll see whether the path reported by the getResource() call is a valid path in your jarfile.

  • Image resources in Jar file

    Hi all,
    I have a jar file having some image resources. When i run this jar file stand alone, it successfully loads the image resources from within itself. But when i use this jar file as library in some other application (with the class path defined in menifest file) it fails to load these images resources.
    Any idea what's going wrong?
    Regards,
    Ghaznavi
    PS: I am using getClass().getResource() method to locate image resources.

    Just in case you didnt know, when you use file names from with in a JAR, the file names ARE case sensative.
    So in a normall app, if you were linking to a file that was in ThisDirectory/ThatDirectory/filename.txt, could link to like this
    ThisDirECTory/thatdirectory/filename.txt
    or this
    THISDIRECTORY/thatdirectory/filename.txt
    but when your app is coming from a JAR you must specifie the filename exactly how it exists on the hard drive.!
    Graham

  • Can't run JavaFX app as a jar file from command line

    I'm trying to build a JavaFX app from scratch (that is, by including the jar file from the JavaFX SDK rather than by using the special JavaFX project type from NetBeans). It runs fine in NetBeans. However, when I try to launch it as a jar file from the command line (using "java -jar dist\TestApp") I get the following. Has anybody seen this before, and if so how can I fix it?:
    *** Fallback to Prism SW pipeline
    Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLink
    Error: Can't load library: C:\dev\TestApp\dist\bin\mat.dll
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
    289)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:68)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
    pl.java:145)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
    27)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:97)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\dev\RedactionT
    oolPrototype\RedactionToolPrototype.Core\dist\bin\mat.dll
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoad
    er.java:155)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoad
    er.java:85)
    at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:
    30)
    at com.sun.glass.ui.Application$1.run(Application.java:28)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:26)
    at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
    at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
    Factory.java:20)
    at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
    Factory.java:17)
    at com.sun.glass.ui.Application.Run(Application.java:51)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
    279)
    ... 5 more

    Unsatisfied link means that Java is trying to access a native library, but it cannot be found. As to why this error is being thrown, here is my guess:
    If you open up one of the sample jars with a zip viewer, you will see that the Manifest file has the following entries:
    >
    Manifest-Version: 1.0
    JavaFX-Version: 2.0
    implementation-vendor: Oracle
    implementation-title: BrickBreaker
    implementation-version: 1.0
    JavaFX-Application-Class: brickbreaker.Main
    Created-By: JavaFX Packager
    Main-Class: com/javafx/main/Main
    >
    In other words, a JavaFX project works a bit differently than a normal Java project. com/javafx/main/Main is used as the Main class and your "Main" class is called later.
    If you are trying to build this from a normal Java project, then com/javafx/main/Main will not be created and it will call your Main class right away. Thus, whatever setup is needed to run JavaFX will not occur.

  • How to use resource in jar

    my application use some images in directory /images;
    and i put the directory in my jar;
    and in my .java i wirte
    somefunction("images/aaa.jpg")
    it cannot be found.
    why��
    it's like this
    -app/
    -app.java
    -images/
    -aaa.jpg

    Try to read this :
    http://forum.java.sun.com/thread.jsp?forum=31&thread=447141&tstart=30&trange=15
    Maybe it will help you as it helped me

  • Deploying one app in multiple jars / wars

    Is it possible to split up an application into two or more jars / wars,
              and still be deployed as a single application. Our requirment is such
              that we need to do that, but I can't seem to find a way to make it work.
              Thanks Shehzad
              

    john,
    The doc instructs to download oracle fusion middleware 11g, which is around 1gb, by this it becomes a heavy application.
    Is there no work-around to get only the necessary components viz ADF runtime libraries to be used in WAS 7.0 to get the app deployed?
    I am little tangled here.... Pls help me to know the structure...
    Thank you.
    Edited by: hemanth on Jul 13, 2011 9:54 AM

Maybe you are looking for

  • Bluetooth on Satellite U400

    Hi I recently bought a new Satellite U400-15e and assumed it had bluetooth installed. After switching on the communication switch I set my phone to search for devices but it found nothing. I tried searching a few times with the same result. So I now

  • DISPLAY variable in R12 Forms/Web tier

    Hello everyone, Just wanted to clarify something about the DISPLAY variable in R12 Forms/Web Tiers.  Is it necessary to have DISPLAY variable set to an active X session(Vnc) server session on Forms/Web Tiers? I understand that we need to do it for CM

  • WRT54G v.6 loses wired/wireless connection after 2 hours

    I have been trying for two weeks to get my router to maintain connection to both my wired and wireless computers.  It drops after 2 hours. It says it is connected but I can't get anywhere.   I have DSL with a static address.  I put the static IP on t

  • Error on page msg

    I have an error on the page when I hover over a link that supplies data in the form of a URL, other links are fine. In the server behaviors panel it highlites the "go to detail page for PHP" when I look at it it says "the field ............ was not f

  • Is the Zoom H4n compatible with GB'08?

    Hi everyone, I'm thinking of buying a portable recorder to use when I'm away from home. In hotels etc. I'd like something that I could rec acoustic guitar + vox with, and then when I get home, put this info into GB'08 for mixing, overdubbing etc. I'm