How to reload Properties class

Hi,
I am using the following code to reload ResourceBundle.
Now I have decided o switch from ResourceBundle to Properties.
I would liek to know the modifications needed in this code to reload Properties class.
When I use the same code I am getting NoSuchFieldException when the method 'getDeclaredField("cacheList")' is called.
Class<Properties> type = Properties.class;
Field cacheList = type.getDeclaredField("cacheList");
cacheList.setAccessible(true);
((Map)cacheList.get(Properties.class)).clear();
Please help.
Thanks in advance,
Neelambary

Why don't you just use clear() and load(InputStream)?
regards
slowfly

Similar Messages

  • How to reload the class without reload th browser?

    thanks

    sorry,I wand to reload the my applet class ,because I want to use the javascript
    to change th obj file that I had load with the load class.Thanks.

  • Properties Class, How does it work

    Hi
    I was struggling to find how to use Properties Object, to read properties file, then I saw the following solution:
    fis = <classname>.getClass().getResourceAsStream("<prop file>"); (1)
    prop = new Properties();(2)
    prop.load(fis);(3)
    fis.close();(4)
    This works fine, but I am not able to understand, how does it work?
    <classname>.getClass() should return a class object, and this class must be havaing getResourceAsStream() method, which is used by the properties object. But what is the need of first getting a "class" object. Our aim is to open the Properties file, then why do we need any reference to the current class.
    Can anybody explain the jargon of the line -(1)
    Gaurav

    the Class class is defined in the lava.lang package. The java virtual machine (JVM) uses a class loader to load class definitions from wherever <g> into memory, ok? The Class class represents the JVM's internal holding of a class definition (as opposed to instances of the class itself).
    To get the Class for any class, you can use the getClass() method on any object, or you can use the <classname>.class syntax. Either way, you get an instance of Class.
    The Class class contains some utility methods about class definitions prresent in the JVM. Importantly, the Class object for a class contains a reference to the class loader that loaded the class. You get it with the getClassLoader() method. The class loader is a thing that knows how to get a class definition from a local drive, or of a jar file, or off the web (if you are using an applet), or whatever. If one class needs another class to work, the class loader knows how to get the definition for that other class.
    Say I have a class
    class Foo {
       int bar(Baz baz);
    }and another one
    class Baz {
    }And both of these are in a jar file at http://z.com/applet1.jar
    An instance of URLClassLoader will be used to fetch class Foo. When Foo needs the definition of Baz, that same loader will be used to get Baz.
    A jar file (or a directory on your local drive) can contain anything at all, not just .class files. It might contain .prioperties files. These are called "resources". If you bundle them up with your class files, then the class loader that loaded the class files can also get them. So if your widget has gif files that it uses for icons, you just bundle them all up together.
    Of course, Class.getResource() is just a convenience method for Class.getClassLoader().getResource().

  • How to reload classes on redeploy

    I want to reload the classes of an EJB every time I redeploy it without restart the server (I use JBoss).

    well actually I use two different versions of JBoss.
    - At work I use Jboss 4.2.2GA, using hot deployment (files are deployed to a directory app.ear in stead of deploying an actual ear file). For this type of deployment to work, the application.xml file MUST be modified before the server will see that the application is changed
    - at home I use JBoss 5.01GA and just deploy the ear file from netbeans, which works perfectly.
    From what you say, I gather you are deploying just the EJB jar, not an EAR. Perhaps you should try it like that.
    Also: I believe there were many problems with JBoss 5.0 that were fixed in JBoss 5.01, so I would verify the version that your host is running.

  • How to reload the screen when changing languages in JavaFX 2?

    I'm beginner with javaFX and i need to change language of the screen. but i have no idea how to reload the screen when the language was changed. The application have a button where have the language available. I want just refresh screen when the user change language.
    Here is the start method to show the stage.
        @Override
        public void start(Stage stage) throws Exception
            this.stage = stage;
            Locale locale = Locale.getDefault();
            ResourceBundle rb = ResourceBundle.getBundle("resources/Label",locale);
            loader = new FXMLLoader(getClass().getResource("FXMLDocument.fxml"),rb);
            root = (Parent)loader.load();
            FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
            controller.setMain(this);
            scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
    here is the function to change the language(in the same class with start function),the rb is the new ResourceBundle:
        public void refresh(ResourceBundle rb)
              //change the language here
    1. I don't want to use the resourceBundle to get value in resource file and set label in scene one by one.like following:
    this.btnLabel.setText(rb.getString(key.test));
    2. I don't want to reload the scene,like following:
        public void refresh(ResourceBundle rb)
             try
                loader = new FXMLLoader(getClass().getResource("FXMLDocument.fxml"),rb);
                root = (Parent)loader.load();
                scene.setRoot(root);
                FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
                controller.setMain(this);
            catch(Exception err)
                err.printStackTrace();
    So do we have a solution to just set the resourceBundle and reload the scene easier?
    Thanks and best regards!

    Your option 2 (reload the FXML for the scene using the new resource bundle as a parameter), is the way this would normally be done and what I would recommend.
    Failing that, you could use option 1 of individually resetting the label text of labeled items (I don't really recommend this).
    Why don't you want to use option 2?
    Perhaps it is because there is some internal state of the UI which differs from the initial state when the the UI is first loaded (e.g. user has typed text in a text field and you want to preserve that).  If that's the case you will need to either go with your option 1 of individually resetting the label text of labeled items, or implement something which preserves the UI state and user data by saving it in memory or to disk, reloading the UI via the FXMLLoader (essentially your option 2), then restoring the UI state and user data to what it was before the language change.  Preserving and restoring the modified state seems complicated to me if you have a lot of state, so I wouldn't really advise this approach unless you really needed it.

  • How to add a class in a project?

    Hello!
    i'm a beginner in developing and i don't know how to add a class in a project in Sun Java Wireless toolkit 2.5.2...
    The name of my project is essai2 and i already put a class, LogoMIDlet and now i want to put my new class ComBasique, how can i do that?
    and do you know if there is a program for bluetooth in order to connect my Nokia 6680 to another device that have a bluetooth?
    thanks a lot for your answer!
    Sophie

    how to change the class name after the project is created.In NetBeans, right click the class name either in the declaration or constructor, select Refactor --> Rename... and follow the dialog.
    You can refactor --> rename anything that is not in a guarded block. For those, there are options via the properties window.
    db

  • How to use properties file

    Hi,
    I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
    My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
    How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
    I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
    ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
    resBun..getString("name");
    After running the program i am getting the following errors:::::
    Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
    at PropertiesReader.main(PropertiesReader.java:4)
    What is the issue? How to use properties file?
    Waiting for reply.
    Thanks

    Still getting same exception. As you explained i tried like the below:::
    1. I am using ant as build tool.
    2. My properties file is for database configuration
    My properties file is::
    database.properties (inside myProject/properties)
    JDBCDriver=org.gjt.mm.mysql.Driver
    JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
    My java package structure is
    WEB-INF/src/java
    WEB-INF/src/classes
    For build WEB-INF is the base directory and build.xml is inside the src directory
    In my build.xml i wrote the following lines for compilation::
              <target name="compile" >
                   <javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
                        <classpath refid="class.path"/>
                   </javac>
    <copy todir = "src/classes" >
    <fileset dir = "../properties" />
    </copy>
                   <jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
              </target>
    I am copying properties file to the classes directory.
    Now in java file which is inside /WEB-INF/src/java, I wrote::
    try {
    Properties programProps = new Properties();
    InputStream is = getClass().getResourceAsStream("/database.properties");
    if(is == null)
    throw new IllegalStateException("Properties file missing ");
    programProps.load(is);
    System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
    is.close();
    } catch(Exception e) {
    e.printStackTrace();
    After compilation in my classes directory i am getting database.properties file and my java file with package.
    At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
    Now tell me where is the fault. Why again i am getting exception.
    Thanks

  • Properties class not available on remote stylesheet

    dreamweaver cc will not apply style classes if the  css is on remote server.  I have to download the style sheet in order for the classes to appear in the properties/class dropdown tool.  what happened to live view and how do I change this so it works with a remote css?

    That's how it works for me, too. 
    Just download the min.CSS file from the remote location and put it into your site folder.  With Bootstrap, I don't necessarily have to link to my local style sheet.  I can still reference the CDN version in my code.  But If I want to work with Bootstrap classes, etc... I have to have the CSS file in my site folder.
    Hope that helps.
    Nancy O.

  • Reloading support classes in a web-app?

              Hi,
              I had previously been successful in compiling classes
              to a directory which was specified in the weblogic.properties
              file as the weblogic.httpd.servlet.classpath. If a class
              were recompiled, the updated .class file would be reloaded.
              However, now we're adhering to the java web application hierarchy,
              where weblogic.httpd.servlet.classpath doesn't apply. Is
              there a way of specifying a directory which should reload
              updated ,class files?
              Thanks,
              j.joseph
              

    You should not put application scope objects in your session regardless of
              its size (which session would you put it in anyways?). Put it in your
              application scope servlet context, which is available to all JSPs and
              servlets. You can do more fancy things but this should be okay.
              Tinou Bao
              www.tinou.com
              "Zaska" <[email protected]> wrote in message news:3b169cff$[email protected]..
              >
              > Hi,
              >
              > I have a situation where I must read data from the database when a web
              application
              > starts. I should store that data somewhere (not to session object, because
              it
              > might grow to large). What could be a good place to save a big object
              containing
              > data which is afterwards retrieved from allmost all JSP/Servlets in the
              same application?
              > I can use database only once, when the application is loaded.
              > Br -z
              >
              

  • How can I Create Class Diagram and save as image in Java

    Hi
    I have to make a project in java that will generate class diagram of the input class file.
    I have some knowledge of listing methods/properties of a class file in text from but don't really know how to draw a class diagram model (JBuilder 2005 such class diagram whenever a class is compiled). I have to save that class diagram in an image file as well.
    Please guide me what must be my line of action to follow. I need some suggestions on urgent basis.
    Thanx in advance
    Regards

    Hi
    My problem is that I have to construct toll like JUDE. What I need from this tool is just to simply draw the diagrams and save in an image format.
    So I need to know how to draw the diagram and save in an image file. I don't know about the drawing libraries available in Java. Kindly help me
    Regards

  • Just changed HD, saved ff bookmarks from previous, how to reload them into the new ff i just downloaded?????

    just changed my HD. using XP. before the change, i saved the bookmarks to a file. i just put that file onto my desktop and can't figure out how to reload all of my previous bookmarks into the new firefox. when i do a search under desktop, that file isn't listed to import.
    what to do?

    See also:
    *http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox
    <br />
    Make sure that the backup file with the bookmarks has the correct file extension: .html for a HTML backup and .json for a JSON backup.<br />
    You can check that via the right-click context menu of that file and open the Properties.<br />
    If you are not sure about the file type then you can open the file in Firefox via "File > Open File"<br />
    A JSON backup will show as one long text line without line breaks and a HTML backup as a web page with clickable links.
    A JSON backup starts with: <b><nowiki>{"title":"","id":1,"dateAdded":</nowiki></b><br />
    An HTML backup starts with: <b><nowiki><!DOCTYPE NETSCAPE-Bookmark-file-1></nowiki></b>
    Add quotes ("") around the name to rename the file to the correct file extension if the current file extension is hidden or if it is otherwise not working.

  • How to dropjava applet class

    Good afternoon everyone:
    i have a question about Oracle JVM.
    In my JSP file there is a applet call.
    After I load the JSP file, the class seems
    to be load into the Oracle Database, and even
    i modify the class is no useful, how can i
    reload the class from DB?
    thanks
    null

    Thanks for your comment .. but it sounds lots of encryption/decryption
    involved.. I need somthing very simple... i have seen this code which does this.. here is the code but i am not an javascript expert .. so please
    if someone gets any clue let me know...
    here is the code ... it just a part of the drop down menu that 's
    why it has <a class="drop" syntex in front of it ...
    <a class="drop" href="javascript:AnyApplet('y')">My Applet</a><br></div>

  • RE: How to debug enhanced classes

    The line number information for classes is not affected by the
    enhancement process. For example, the pre-enhanced code 'this.foo = 2'
    looks like the following in pseudo-bytecode:
    aload_0 // load 'this' onto stack
    iconst_2 // load '2' onto stack
    putfield <foo> // place '2' into field 'foo' of 'this'
    The replacement code, 'jdoSetFoo (this, 2)' looks like this:
    aload_0 // load 'this' onto stack
    iconst_2 // load '2' onto stack
    invokestatic <jdoSetFoo> // invoke static method jdoSetFoo with the
    args
    The two bytecode blocks are the exact same length, and this holds true
    for setting fields as well.
    Java line number tables mark the bytecode position and length of each
    source code line. Because the enhancer doesn't change either of these
    properties, the line number tables remain correct, and line numbers
    match even after enhancement.
    If you thought you saw line number discrepencies, I'd be very very
    interested in seeing a specific example, because I just don't see how
    they could possibly exist, with the exception of 2 places:
    1. Cloning code. The enhancer adds special instructions after cloning.
    2. Static initializer blocks. Again, the enhancer adds to the static
    init block so that classes register themselves with the JDOImplHelper.
    -----Original Message-----
    From: David Ezzio
    To: Tech Trader JDO List
    Sent: 8/2/01 6:05 PM
    Subject: Re: How to debug enhanced classes
    In TT Beta 1, I noticed that the line numbers were not matched up
    correctly for the enhanced classes. It's a bug. Don't know if Beta 2
    is supposed to have fixed it. I used BugSeeker2.
    David

    Alex
    I'm getting the same problem you had. I can't debug my enhanced classes
    with JBuilder 6. Have you solved this question?
    TIA
    Arthur
    Roytman, Alex wrote:
    Eric,
    I meant source debugging not just stack traces
    I could not do it with JBuilder. I do not know how debugger works but
    debug info in binaries do not match unenhanced source code
    Alex
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Thursday, August 02, 2001 1:34 PM
    To: Roytman, Alex; JDO-ListServ
    Subject: Re: How to debug enhanced classes
    Shouldn't you be able to debug them just like normal classes? The line
    numbers in the stack traces shoud all be the same as those found in an
    unenhanced class.
    Of course, if you mean debug a problem with the JDO implementation,
    well,
    you don't have the source anyways so what good would it do? :)
    -Eric
    ----- Original Message -----
    From: "Roytman, Alex" <[email protected]>
    To: "JDO-ListServ" <[email protected]>
    Sent: Thursday, August 02, 2001 1:07 PM
    Subject: How to debug enhanced classes
    Has anybody came up with a method to debug enhanced classes?

  • Using properties class

    How do I extract keys with values of pcoa245 for example using the Properties() class. The file is shown below. Thanks for your help.
    pcoa245= C .. QMan_2 (tsorial@pcoa245)
    pcoa245= Q .. QMan_3 (tsorial@pcoa245)
    sun122= C .. Testing (tsorial@pcoa245)
    sun122= C .. testing ([email protected])
    sun122= R .. sasls01 (tsorial@LOCAL)

    Maybe it will help if I show you what I have so far:
    Properties p=new Properties();
    String sFile=FileOps.FileInDir(System.getProperty("user.dir"),"server_jobs.txt");
    p.load(new FileInputStream(sFile));
    //Add job item to server node
    jobItem=new DefaultMutableTreeNode(p.getProperty(zServer.getName()));
    serverName.add(jobItem);ServerName is a node within a JTree. I am trying to extract the lines (not just one) that start with pcoa245 and place the strings after the "=" into the tree. How would I extract these lines using the properties class.

  • How do I find classes in a package

    Hi,
    I am working on an automation tool which is to be used for testing public API's in our product. The tool is supposed to work this way:
    1. A developer of the API adds a new java file containing the test code for the API in a particular package (which the tool defines). Then he compiles and places the stuff in a jar. There is also a driver class in this same package path defined by the test tool. E.g.
    driver class: com.aaa.bbb.DriverClass
    new API test file: com.aaa.bbb.TestFile
    Now the driver file's job is to find out all the other classes in this particular package and then do some processing. When I tried doing the getPackage() on this driver class to find out about the package I got back a null.
    Question 1: How can I get the package for a particular class (An ugly way to do this would be to strip it out from the classname)
    Question 2: How can I find out what other classes are there in a package?
    Thanks in advance on this.
    Nikhil Singhal
    You can also send me mails at
    [email protected]

    hai
    i have the same problem to finding the classes in package...
    in my case i know the jars name and i have loaded
    classes using code
    ResourceBundle bundle = ResourceBundle.getBundle("source\\ClasssPath");
    StringTokenizer stToke = new StringTokenizer(bundle.getString("ClassPath"),";");
    String temp;
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    while(stToke.hasMoreTokens())
         temp = stToke.nextToken().trim();
    if(temp.endsWith(".jar"))
    JarFile jar = new JarFile(new File(temp));
         Enumeration en = jar.entries();
         String pathStr;
         while(en.hasMoreElements())
         pathStr = en.nextElement().toString();
         System.out.println("pathStr ="+pathStr);
         if(pathStr.endsWith(".class"))
              System.out.println( classLoader.getResource(pathStr));
              System.out.println(classLoader.loadClass(pathStr.substring(0,pathStr.indexOf(".class")).replace('/','.').trim()));
         else classLoader.loadClass(temp);
    here i am getting the classes in that package using code
         String[] filLis = new File("//it//sella//converter//ptlf//startup//").list();
         int length = filLis.length;
         while(length-- >0)
         System.out.println(">"+filLis[length]);
    but its returnign the class when this classes in locale folder(i.e)its not getting the classes in loaded memory...
    so how to retrieve the class files names using package structure name...
    (i am having more then 20 jars files, inthat inside the jar samepackage structue may appear in more then one jars )
    pls help me in this field..
    Thanx

Maybe you are looking for