Using ResourceBundle and Locale in an Applet

hello,
i worked out a little application to use with multilanguage support.
i wrote two classes so i can start the application within a jar file located on my computer and anotherone to launch it as an applet...
for development i use Eclipse; when i try to run it in eclipse everything works fine (although i limit the access of the applet!)
when i try to run the applet in IE i get the error message:
java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)i did not use the function "System.getProperty("user.dir")" in MY code which is referred!
so i guess its one of the included packages:
ResourceBundle | Locale
how can i solve this problem as its working in the limited access applet in eclipse??
thanks in advance

note: i do load the .properties file from the JAR package, not from hdd!
here is my code
import java.util.Locale;
import java.util.ResourceBundle;
public class Xlocale {
     private Locale locale = Locale.ENGLISH;
     private ResourceBundle thisLocaleRB;
     public Xlocale(String aXlocaleName, String aLocale) {
          setLocale(getLocale(aLocale)); //if you leave this line it won't work *hmm?*
          if (thisLocaleRB == null || getLocale() != thisLocaleRB.getLocale()) {
               try {
                    thisLocaleRB = ResourceBundle.getBundle(aXlocaleName, getLocale());
               } catch (Exception e) {
                    //System.err.println(e.getLocalizedMessage()+" ["+System.getProperty("user.dir")+"\\"+aXlocaleName+"_"+getLocale()+".properties]\n");
     public String getString(String key, String dv) {
          String val = thisLocaleRB.getString(key);
          if (val == null)
               return dv;
          else
               return val;
     public void setLocale(Locale l) {
          this.locale = l;
     public Locale getLocale() {
          return this.locale == null ? Locale.ENGLISH : locale;
    public static Locale getLocale(String loc)
        if(loc!=null && loc.length()>0)
            return new Locale(loc);
        else
            return Locale.ENGLISH;
}

Similar Messages

  • ResourceBundle and Locale ?

    Hi All,
    Anybody please tell me what is the use of ResourceBundle and Locale ?
    Can I use it in my util/Servlet class ?
    What is the advantage of using it ?
    Please reply soon
    Thanks
    Harish Pathak

    ResourceBundle is a utility class provided by the java.util package which internally uses ClassLoader and loads files which .properties extension.
    Incase you wish to make your application Region or Language specific. Then you can use the Locale concept of ResourceBundle and have multiple property files for each region.
    You can set the Locale for the ResourceBundle like en_US where region is US and language is en (english) and it will load the appropriate property file.
    --- For your information
    Gets a resource bundle using the specified base name, locale, and class loader.
    Conceptually, getBundle uses the following strategy for locating and instantiating resource bundles:
    getBundle uses the base name, the specified locale, and the default locale (obtained from Locale.getDefault) to generate a sequence of candidate bundle names. If the specified locale's language, country, and variant are all empty strings, then the base name is the only candidate bundle name. Otherwise, the following sequence is generated from the attribute values of the specified locale (language1, country1, and variant1) and of the default locale (language2, country2, and variant2):
    baseName + "_" + language1 + "_" + country1 + "_" + variant1
    baseName + "_" + language1 + "_" + country1
    baseName + "_" + language1
    baseName + "_" + language2 + "_" + country2 + "_" + variant2
    baseName + "_" + language2 + "_" + country2
    baseName + "_" + language2
    baseName
    Candidate bundle names where the final component is an empty string are omitted. For example, if country1 is an empty string, the second candidate bundle name is omitted.
    getBundle then iterates over the candidate bundle names to find the first one for which it can instantiate an actual resource bundle. For each candidate bundle name, it attempts to create a resource bundle:
    First, it attempts to load a class using the candidate bundle name. If such a class can be found and loaded using the specified class loader, is assignment compatible with ResourceBundle, is accessible from ResourceBundle, and can be instantiated, getBundle creates a new instance of this class and uses it as the result resource bundle.
    Otherwise, getBundle attempts to locate a property resource file. It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties". It attempts to find a "resource" with this name using ClassLoader.getResource. (Note that a "resource" in the sense of getResource has nothing to do with the contents of a resource bundle, it is just a container of data, such as a file.) If it finds a "resource", it attempts to create a new PropertyResourceBundle instance from its contents. If successful, this instance becomes the result resource bundle.
    If no result resource bundle has been found, a MissingResourceException is thrown.

  • How to use packages and jar files for applet?

    Hi!
    My applet takes a class say a.class.
    Now this class depends on other classes that are packaged
    in a directory and put separately.
    I want to put this applet on the web.
    So how do I manage the .class files in he package.
    I have tried using jar file format.But I was not able to get it working.
    Can someone please help me?
    Thanks

    Use Archive instead of codebase:
    <APPLET CODE="MyApplet.class" ARCHIVE="MyApplet.jar" WIDTH=400 HEIGHT=300></APPLET>

  • FWSM: AAA authentication using TACACS and local authorization

    Hi All,
    In our setup, we are are having FWSMs running version 3.2.22 and users are authenticating using TACACS (running cisco ACS). We would like to give restricted access ( some show commands ) to couple of users to all devices. We do not want to use TACACS for command authorization.
    We have created users on TACACS and  not allowed "enable" access to them. I have also given those show commands locally on the firewall with privilege level 1. and enabled aaa authorization LOCAL
    Now , those users can successfully login to devices and execute those show commands from priv level 1 except "sh access-list".  I have specifically mentioned this
    "privilege show level 1 mode exec command access-list"  in the config.
    Is there anything i am missing or is there any other way of doing it?
    Thanks.

    You cannot do what you are trying to do. For (default login you need to use the first policy matched.
    you can diversify telnet/ssh with http by  creating different aaa groups.
    But still you will be loging in for telnet users (all of them) using one method.
    I hope it is clear.
    PK

  • Getting String using ResourceBundle and XLIF resource bundle.

    Hello,
    I am using Jdev. 11.1.1.2.0. I am trying to use XLIFF resource bundle in the Model project and trying to get string from the bundle using following code. I am getting MissingResourceException. if I use Property Bundle, it works fine.
    public String getMessage(String code)
    return ResourceBundle.getBundle("model.ModelBundle").getString("MESSAGE1");
    Any help to make it work with XLIFF resource bundle will be appreciated.
    Thanks,
    Amit
    Edited by: Amit Patel on Apr 1, 2010 10:23 AM

    To get the values from the resource bundle, you use the <fmt:message> tag
    <fmt:message bundle="${appbundle}" key="lbl.accountnum"/>

  • Resource Bundles and Locales

    Hi!!
    I am researching Resource Bundles and how they work and have a question. Do you have to use Locales to determine which bundle to use? You see I am developing a product that will only be used in the US but will be used by several different companies. I would like to use a resource bundle for each company instead of for each country!! Is this possible? and if it is, how?
    Thanks for your time

    If you want to have default values, I would suggest using ResourceBundles and just sending in a Locale with the variant of the company. That way if your application ever needs to be localized it won't take much to change it. Your properties files would be named baseName_languageCode_CountryCode_Variant.properties.
    It has been a great advantage for the program that I am developing.

  • - Use of ResourceBundle without Locales

    Hello!
    I'm trying to use a ResourceBundle to store properties that arn't locale-specific - its a sort of look-and-feel type arrangement. The way more specific ResourceBundles inherit properties from more general ones would be really useful, but since its not a locale that's used to pick a particular bundle I'm having trouble working out how I can use it for this purpose.
    Has anybody used ResourceBundles for non-locale specific uses before, or does anyone know of anything else that might be more appropriate?
    Thanks loads for any help!!
    Nicola

    Hello!
    I'm trying to use a ResourceBundle to store properties
    that arn't locale-specific - its a sort of
    look-and-feel type arrangement. The way more specific
    ResourceBundles inherit properties from more general
    ones would be really useful, but since its not a
    locale that's used to pick a particular bundle I'm
    having trouble working out how I can use it for this
    purpose.
    Has anybody used ResourceBundles for non-locale
    specific uses before, or does anyone know of anything
    else that might be more appropriate?
    Thanks loads for any help!!
    NicolaYes, you make up your own Locales with anything you want in place of the language, country, and variant. As long as you're not setting the Locale, it works great!
    ResourceBundle laf = new ResourceBundle.getBundle("skins.properties", new Locale("flavor", "chocolate",""));will get all resources in skins.properties and over-riding entries from skins_flavor_chocolate.properties".

  • How do I stream iTunes content to my home theatre using any combination of a MacBook Pro, an iPhone 4s, and a PS3 using only a LOCAL network?

    I have found many solutions to this problem assuming home internet access, but I only have access to the internet via my iPhone. I do not want online capability in my PS3. All I want to be able to do is control iTunes on my MacBook, and hear/view the content on my home theatre. I would prefer to use my iPhone as the remote for iTunes, and do not want to add the monthly cost of home internet to this equation. I do not require access to anything on my MacBook except iTunes in this application. I would prefer to use iTunes and stream to my home theatre, as opposed to setting up my MacBook as a media server and using the PS3 interface. Is this possible? Can I accomplish this goal using a local network? Can I create a wifi network on my MacBook to do this, or do I need a router? I am looking to spend as little as possible on this project, as I plan on moving to a more urban area soon, and will be buying Apple TV and subscribing to home internet service when this happens.

    Get an AirPort Express.  It has an audio out which you can connect to the line-in on your home theatre system.  All the other devices will talk to the AirPort Express and stream content to it via wi-fi.

  • How do I set the HELP menu to use Indesign's local HELP files on the hard drive and not the web?

    How do I set the HELP menu to use Indesign's local HELP files on the hard drive and not the web?
    CS 5.0 launches the internet browser.  > TO SLOW I DONT WANT THIS.
    CS 3.0 uses the local help files > I WANT THIS FOR 5.0.

    You're not speaking to the right forum for your request. Help is a Suite-wide feature and here is the forum where the Help application is discussed, and where the proper Adobe people hang out:
    Community Help Application

  • Download local file using Servlet and JSP

    Hello,
    I will like to use a browser to download file on local system using serlvet and Jsp technology. Does anyone have any idea how to do it?
    Any comment will be appreciate.
    Thanks

    Well you can just put the file in a folder that is accessible to the web server. Then have a link point to that file. That will cause the web browser to download the file.
    hattan

  • I am planning to buy ipad 2 wifi   3g verizon carrier, will be taking it to india need to know if the same can be used with the local providers there or would the ipad be locked and restricted only to verizon

    I am planning to buy ipad 2 wifi   3g verizon carrier, will be taking it to india need to know if the same can be used with the local providers there or would the ipad be locked and restricted only to verizon

    I'm fairly sure the Verizon CDMA iPad 2 had no GSM sim slot. So it won't work with any other carrier except Verizon.
    As far as the AT&T version goes, it should technically work but will not support 4G/LTE cellular bands.
    Given iPad 2's are no longer being sold, I doubt any  that could be bought would have a warranty still. Or have at most very little of it left.
    Why an iPad 2?  its now 3 generations behind the current one.
    Perhaps an iPad 4 would be a better choice.

  • When to use Global transaction and Local Transaction only

    Hi All,
    Could you please help with this question thats been troubling me from quite long time.
    When to create Global & local Transactions and Local Transaction Only while creating Data source on oracle Application Server 10 G.
    Do I get any advantages by using Global & local Transactions for creating Data Source
    Thanks In Advance.
    Regards,
    Ajay Kumar .Akula

    mattyG wrote:
    What is the difference between a single-process shared variable and a local variable?
    A single process shared variable is more like a global variable, because it can be accessed from any VI in your hierarchy. Local variables are strictly local to the single VI where they reside.
    Shared variables are a relatively new feature, while local and global variables are ancient. As such, shared variables are in many ways more modern and integrate better into state-of-the-art coding guidelines.
    Shared variables contain error terminals so you can enforce execution order. local variables have no such thing.
    A shared variable can stand on its own, while a local variable is always tied to a front panel object.
    You need a project for shared varaibles.
    You can easily turn a single process shared variable into a network shared variable later in the development, without the need to rewrite any code.
    LabVIEW Champion . Do more with less code and in less time .

  • Query in reg the use of ResourceBundle and Properties in my webapplicatiom.

    I have property file which have some values. I use ResourceBundle to get values by passing the key to getString method. But the problem for me is that my webapplication is running in tomcat server. When i add a new value in property file i could not get that value. I want know which method is used to reload the property file which has changed without restarting my tomcatserver.
    Regards
    Richard

    Question 1: Yes I have done this.
    Question 2: Yes, but you would need to configure you DHCP server to hand out the additional option 150 address.
    Question 3: Yes the .xml files for phones will be.  The default firmware will be as well. If you upgraded firmware from the default you will need to upload it on that server as well.
    Question 4 :If the TFTP server does not respond, the IP phone falls back to the last
    used configuration stored in NVRAM. 

  • Referencing a "locally installed" Java applet from a server-based HTML page

    How does one reference a "locally installed" Java applet from a server-based HTML page (i.e. via the applet, object, or embed tags)? I have seen references in documentation that this is possible, but I have not seen any examples. I have tried a few things, but nothing seems to be working.
    Some background...
    I'm working on a web site that aggregates Internet video. For many users, I would like the site to work "without" requiring Java to be installed (or any prompts, etc.). This version of the site allows users to stream videos directly over the Internet and does not require any sort of access to the local system.
    However, in addition, I have a download manager that can be installed on the local system. Currently, it's a Windows-based "service" that is always running in the background, downloading files, etc. (with plans to later support other OSes).
    My dilemma is trying to communicate between my web site running in the local browser (executing JavaScript code) and the download manager. I call this component the "gateway". I need the gateway to be able to do the following:
    1) Pass user credentials from the web browser UI to the download manager (so it can communicate with my servers).
    2) Check the status of downloaded videos
    3) Launch a local media player (such as Windows Media, QuickTime, etc.) (or perhaps tell the download manager to launch the media player).
    Under Windows XP, I have an ActiveX control that can do these things. It communicates with the download manager via reading/writing to a shared XML configuration file.
    Unfortunately, under Vista and IE7 Protected Mode, ActiveX controls have become very restricted and my gateway no longer works. As such, I am looking at using Java for the gateway (also giving me the additional benefits of supporting additional browsers and OSes).
    From my understanding, I believe I can created a "face-less" Java applet, whose methods can be called from JavaScript. Ideally, I'm thinking I could install the applet onto the local system at the same time the download manager is installed. This would give the applet the security permissions it needs to communicate with the download manager.
    Thanks for any help and suggestions!

    Hi,
    Put the .jar file and the .class file in the path mentioned in one of the aliases in the plsql.conf file like /images or create
    a seperate directory and create an alias like /applets "path" in the plsql.conf file.
    <html>
    <body>
    <applet code=com.chartapplet.chart.BarChartApplet
    codebase=/applets/
    archive=/applets/chart.jar width=300 height=200>
    <param name=background value="white">
    </body>
    </html>
    Hope this helps.
    Thanks,
    Sharmila

  • How do you get values of local machine running applet on remote server?

    Hi,
    I have an applet that runs great running the html file on my local machine from a root directory. I've placed my code(java, class, and html files) on the web server and loaded the applet onto a page. The results are merely:
    "Computer Name: localhost"
    "IP Address : 127.0.0.1"
    Instead of:
    "Computer Name: ACTUALNAME"
    "IP Address : 189.40.20.211"
    etc...
    The code is as follows:
    import java.applet.*;
    import java.awt.*;
    import java.net.InetAddress;
    public class IPFinder extends Applet {
    public void paint(Graphics g) {
    super.paint(g);
    try {
    InetAddress localaddr = InetAddress.getLocalHost () ;
    g.drawString("Computer Name: " + localaddr.getHostName (), 2, 13);
    g.drawString("IP Address : "+localaddr.getHostAddress (), 3, 25);
    g.drawString("", 3, 45);
    String str = localaddr.getHostName();
    InetAddress[] localaddrs = InetAddress.getAllByName ( str ) ;
    for ( int i=0 ; i<localaddrs.length ; i++ )
    if ( ! localaddrs[ i ].equals( localaddr ) )
    // g.drawString("Local hostname : " + localaddrs[ i].getHostName () , 3, (i+0)+50);
    g.drawString("Local IP Address("+i+"): " + localaddrs[ i].getHostAddress () , 3, (12*i)+((i+10)+45));
         }} } catch (Exception e) {
    g.drawString("Can't detect localhost : " + e +". Check Network settings.", 3, 60);
    public static void main(String[] args) { new IPFinder(); }
    I'm trying to get Real IP Addresses (as the code was setup to do) from a browser running on the web server. I have read some of the threads in this forum and some mention to use NetworkInterface while others recommended using Sockets (not an option since we do not use them), and another to use a signature as a workaround. Anyone know the best direction to get the results expected?
    Thanks in advance,
    Geoff-

    I have an applet that runs great running the html file
    on my local machine from a root directory. I've
    placed my code(java, class, and html files) on the web
    server and loaded the applet onto a page. The results
    are merely:
    "Computer Name: localhost"
    "IP Address : 127.0.0.1"This indicates that your applet when run over a web
    server has not the rights to query the local name and
    address. Look [url
    http://java.sun.com/j2se/1.4.2/docs/api/java/net/InetAd
    ress.html#getLocalHost()]here. The so-called
    loopback address is 127.0.0.1
    Check your documentation for "signed jar" (or search
    the forum or the sun website) if you want to give your
    applet more rights, but I don't think that this is
    worth the effort in this case.
    gdsimz, since you already started two new threads based on my suggestion, how about at least saying "thank you" or "sorry, didn't help"?

Maybe you are looking for