Persisting a properties object across the whole of my program.

Hello all,
As per usual, sorry for any idiocy on my part and thanks for any guidance.
I have written a wrapper class for the Properties class.
I have an MDI which creates a properties object and loads it at start up, and I have tried to use the same object again (to save any property changes) when the app terminates. However, I get a nullPointerException when I try and use it when the program closes. Below is what I hope are the relevant pieces of code. I don't include it all as it a couple of hundred lines long - but can easily do so if you think it will help. Many thanks once again:
Here is the load properties method:
private void yLoadProperties(){
        String workingDirectory = System.getProperty("user.dir");
        File yFile = new File(workingDirectory + "\\KTProperties.ini");
        YPorperties yProperties = new YPorperties(yFile);
        yProperties.yLoadProperties();
        // Retrieve application name - no conversion required
        yApplicationName = yProperties.yGetProperty("ApplicationName");
}and here is the exit program method with the call the the save properties method
private void yExitApplication(){
        // Save properties back to disk
        yProperties.ySaveProperties();
        // Exit
        System.exit(0);
    }I have also declared the yProperties variable thus:
private YPorperties yProperties;
I was hoping to use the yProperties object anywhere within my program to adjust properties as required. Any help, gratefully received.
Steve

That's just the way Java works. I'm sure someone is able to quote chapter and verse of the Java Language Specification that spells it out, but the basic distinction is this:
A variable declaration has the form: <Type> <variableName> [= <value expression>];.
A variable assignment (which assigns a value to an existing variable) has the form: <variableName> = <value expression>;
When you specify the type of a variable, Java assumes you are declaring a new variable in the current scope, regardless of whether the name of the variable already existing in a enveloping scope. When you don't specify the type, Java will look for an existing variable with that name in the current scope and any enveloping scopes.
In my mind, when I explicitly declared yProperties, thus:> private YPorperties yProperties;> I was making it available to the whole program.With that line you declared a member variable of type YPorperties (shouldn't that be YProperties, by the way?), which means a separate yProperties variable is available as a member of each instance of your class. Note that you already specify the type of the variable yProperties in that line, so there is no need to specify that type again when using the variable further on in your application.
But yes, you are correct in saying that this variable would be available anywhere inside that one instance of your class. However, it is possible in Java to declare a variable with the same name in a different, narrower scope (as you have seen).
Java looks for variables from the narrowest scope outward, so in this case it sees the local variable yProperties before it sees the member variable yProperties.
(BTW for future reference, note that a class or an instance of a class is not a "program" as such. So declaring a private member variable does not make it available to your "program", it makes it available to an instance of a class. The fact that you use that class to start your application is irrelevant)

Similar Messages

  • Why are the apps on my IPad scattered across the whole thing and when I open them they turn to little rectangles in the corner of the screen and I can't even use them or tap on anything. Also when I turn my iPad it doesn't flip the screen over

    Why are the apps on my IPad scattered across the whole thing and when I open them they turn to little rectangles in the corner of the screen and I can't even use them or tap on anything. Also when I turn my iPad it doesn't flip the screen over.

    Hi The next thing to do is to Restore back to Factory Settings this will get rid of any bugs . After Restore use same Apple ID /Password then you should get all your Apps & data back If you still have this problem make an Appointment at Apple Store . Cheers Brian

  • How do I replace font colors across the whole document?

    So I know how to change a certain font across the whole document.
    I can replace let's say, Times New Roman with Arial throughout the whole document.
    However, what if I want to replace a font color?
    For example, I want to change the black 0,0,0,0 with black 40,30,30,100 across the whole document, instead of searching one by one and replacing the existing color.
    I'm using CS5 on PC

    As Peter says, it is better to do with paragraph styles. The above shows where.
    In general, you should be using p. styles with little or not local formatting (depends on use). And for local formatting that is repetitive, character styles should be used.
    Take care, Mike

  • Streaming audio across the whole folio

    We have a client who is interested in creating a "radio" function, where we would stream audio across the whole folio. The desired effect would be that audio would play continuously and uninterrupted on each page of each article.
    I know that there is a way to play a local audio file across the whole folio. We already tested that and it should work just fine, but the client would like the audio to be streamed from the internet because we may not have the rights to embed the audio files.
    Do you know if there is a provision to do something like this from Adobe DPS? We heard that it might be possible by using a set up similar to browser frames, but I was unable to find any documentation about that.
    iPad only.

    We don't support authoring streaming audio and video using the DPS authoring tools at the moment. There's no way to do this with a web overlay as the overlay will get removed from memory once your reader moves away to another article.
    Neil

  • How can I persist a Java object to the PCD via JNDI ?

    Hi,
    I'm trying to persist XML data on the PCD via JNDI. I'm using
    portal version 6.2.0.4.200408172051.
    I followed the instructions in the "Portal Runtime Technology 640"
    document.
    The example they showed was:
    import javax.naming.Context;
    Context context = PortalRegistry.getCentralConfigurationContext();
    Context applicationContext = context.lookup("MyAppName");
    It was possible to obtain 'applicationContext' in the above example by
    using:-
    Context context = PortalRegistry.getCentralConfigurationContext();
    String appName = request.getComponentContext().getApplicationName();
    Context applicationContext = (Context) context.lookup(appName);
    However, any attempt to bind, rebind an object (implementing IStreamSource)
    resulted in NamingExcptions. As did 'listBindings' and 'list' (see below).
    BeanWrapper d = new BeanWrapper("test input");
    applicationContext.rebind("PCD_LOOKUP_KEY", d);
    // where 'd' implements IStreamSource
    class BeanWrapper implements IStreamSource {
    String content = "balh";
    BeanWrapper(String s) {
    content = s;
    public InputStream getInputStream() throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes());
    return bis;
    } // getInputStream
    } // BeanWrapper
    I don't know what I've done wrong. I couldn't find any more documentation
    on this topic...
    Any help would be appreciated.
    cheers,
    Michael
    javax.naming.NameNotFoundException: [Xfs] Object not found. Root exception is javax.naming.NamingException: [Xfs] Object not found
    at com.sapportals.portal.pcd.gl.xfs.BasicContext.lookup(BasicContext.java:840)
    at com.sapportals.portal.pcd.gl.PcdPersContext.lookup(PcdPersContext.java:422)
    at com.sapportals.portal.pcd.gl.PcdFilterContext.filterLookup(PcdFilterContext.java:387)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.basicContextLookup(PcdProxyContext.java:1083)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.proxyLookupLink(PcdProxyContext.java:1170)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.proxyLookup(PcdProxyContext.java:1132)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.getBasicObject(PcdProxyContext.java:1330)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.getBasicContext(PcdProxyContext.java:1306)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.rebind(PcdProxyContext.java:473)
    at com.sapportals.portal.pcd.gl.PcdGlContext.rebind(PcdGlContext.java:1185)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.rebind(PcdProxyContext.java:515)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.rebind(PcdProxyContext.java:683)
    at com.sapportals.portal.pcd.gl.PcdProxyContext.rebind(PcdProxyContext.java:688)
    at com.sapportals.portal.prt.jndisupport.util.AbstractContextWrapper.rebind(AbstractContextWrapper.java:46)
    at com.siemens.pct.employee.cu_selector.CUSelector.saveCuBeanToPCD(CUSelector.java:305)
    at com.siemens.pct.employee.cu_selector.CUSelectorUpload.doUpload(CUSelectorUpload.java:70)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.handleRequestEvent(AbstractPortalComponent.java:700)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.handleEvent(AbstractPortalComponent.java:412)
    at com.sapportals.portal.prt.pom.ComponentNode.handleEvent(ComponentNode.java:250)
    at com.sapportals.portal.prt.pom.PortalNode.fireEventOnNode(PortalNode.java:333)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:627)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:208)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:532)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
    at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:832)
    at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:666)
    at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:313)
    at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
    at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1288)
    at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
    at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
    at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)

    Hi Michael,
    here my comments to your questions:
    0.:[Michael says:]
    "So basically you're saying that under SP10 its not possible to store objects on the PCD ... ?"
    I want to clarify this:
    It is possible to store objects in the PCD in lower releases than SP10 (e.g. SP2). But due to the fact that PCD API is not public before SP10 you should not develop a SP2 iView that programmatically uses the PCD API and complain afterwards because some "tiny" things of it are not working in SP10. It might be that you have to adjust some parts of this SP2 iView.
    The kind of object that can be stored in the PCD depends on the fact if the objects have a corresponding object provider or not. If you want to store iViews, roles or one of the other commonly known portal objects you can do it because corresponding object provider (iViewservice, roleservice, etc.) are always available in a running portal.
    If you want to store objects (like your BeanWrapper class) then you should write a corresponding object provider (what I explained in my first reply).
    1.:[Michael asked:]
    Why does list and listBindings fail ? surely that should just
    list the existing bound objects ???
    Nothing was bound!
    Your code line
    applicationContext.rebind("PCD_LOOKUP_KEY", d);
    throws a NamingException because no object provider for class of object d was found.
    So I gess you did a lookup on  applicationContext.lookup( "PCD_LOOKUP_KEY" ) before you did the list/listBindings and because this
    context does not exist the corresponding "Name not found" exception was thrown?
    A list/listBinding on the applicationContext itself should work even if nothing was bound.
    2.:[Michael asked:]
    Is there not some kind of default object/object provider pair
    that can be used to store base types like Strings/Integers etc ?
    No. There are no default object providers for java string/integers. But for this case "persisting a string or integer value at any PCD context" the PCD offers another way to do it: Just create an additional attribute (of type STRING or INT) and persist the corresponding value in this attribute (of type IPcdAttribute - an extension of javax.naming.directory.Attribute )   
    The code for creating a pcd attribute looks e.g. like this:
    IPcdObjectFactory pcdObjFactory = ((IPcdGlService) PortalRuntime
                                                   .getRuntimeResources()
                                                   .getService(IPcdGlService.KEY))
                                                   .getPcdObjectFactory();
    IPcdAttribute newPcdAttr = pcdObjFactory.createPcdAttribute(     PcdAttributeValueType.STRING,
                                            "new_attrId" );     
    newPcdAttr.set(     0,
              "new_AttrValue" );
    ModificationItem mods[] = new ModificationItem[1];
    mods[0] = new ModificationItem(      DirContext.REPLACE_ATTRIBUTE,
                               (Attribute)newPcdAttr );
    pcdCtx.modifyAttributes(     "",
                        mods );
    Hope, that helps you!
    Regards,
    Jens

  • Duplicating the motion of an object across the stage

    Suppose I have a single moving object on the stage is it possible to replicate the object at regular intervals across the stage WITH the motion?

    Is this motion achieved through actionscript or is it a tween on the stage? If this is a tween on the main timeline on the stage, then you could make that animation a movieClip and play the movieClip at an interval, maybe using a timer. If the animation is achieved using actionscript then write the animation as a function and call the function at an interval, again, possibly using a timer.

  • My 2008 MacBook Pro screen has now got interference across the whole screen. It looks similar to a pre-cable interference from bad reception. What is the problem here?

    My 2008 MacBook Pro has interference across the full screen. It looks similar to a pre-cable TV screen with bad reception. Any idea of what the problem might be?

    Took it to the Apple Store, they determined it's my screen that's messed up (they connected to another monitor, and since the lines didn't mirror onto the monitor it couldn't have been my GPU making the lines but rather the screen itself), so not connected to my wifi issue or a potential logic board issue, so I'm going to get my screen, wifi card, and trackpad (it's been failing too but that wasn't urgent at all) replaced for $330 using their flat-rate repair service which is much better than I imagined in terms of price.

  • My tab bar is really large, how do I get it back to the normal size? It stretches across the whole page.

    I got on my computer this morning and my toolbar was messed up and my tab bar is one really long tab the goes across the page and I don't know how to get it back to the way it was. I fixed my toolbar sort of, but now my concern is how to get my tab bar back to the normal size.

    Welcome to Safari 6 with:
        .   .  t  .   .  a  .   .  b  .   .  s  .   . 
    That are the size of tractor-trailer trucks!
    There is no known way to get them smaller except when you get a lot they will "shrink-to-fit".

  • Over-view discussions of working through the whole suite of programs?

    One things these forums do is allow detailed discussions of say, how to do X task in Y software.
    BUT ... the whole "suite" of video programs is designed for an over-arching process, and I can't find ANYWHERE that the main process is being discussed. Just the bits and pieces of how to use each separately, or perhaps get from one program to another's tool-set & back the easiest and quickest.
    Where does one go to improve one's use of the suite as a suite? Going from Story to Prelude to PPro to Ae to PPro to Sg to PPro to Audition to PPro & off to AME?
    Neil

    I'm not sure what others are using but this is my workflow having worked with the CC suite for less than a year:
    I don't really bother with Prelude as I find Premiere does everything and more, but theoretically I could log, marker, do some (horrible) speech recognition and transcribing before scooting rushes on to Premiere. Prelude occasionally comes in handy for batch transcribing rushes that need to be passed on to facilities without native NLE's. I personally think it's pretty redundant, but happy to be corrected.
    So just import, log, edit in Premiere. Temp titles, effects and rough mix all done in Premiere.
    Specific VFX shots are dynamic linked to AE for more intensive work. Graphics are all prepped in Illustrator and Photoshop prior to importing into AE as layered comps. The links are then just updated in Premiere - no rendering out (at least from AE - all links still need rendering in Premiere for RT playback).
    Send audio clips to Audition that need work (ie. noise reduction, dynamics, leveling off). Save and update in Premiere. I render down my Premiere audio timeline for a final mix and normalise in Audition, but I'm sure there's a more efficient way of doing this.
    I still find Speedgrade a little clunky and foreign, so I'll typically dynamic link shots off to AE that need intensive grading work. I'm familiar with the AE toolkit and find I can pull keys, window and track to my hearts content easily within it. (Still haven't found a grading package as user friendly and efficient as Resolve yet).
    Final checks in Premiere of the finished pictures and mixed audio track before sending off to AME for encoding for delivery. If going to a DVD I'll run the encode through TMPGEnc instead of AME as I find it handles the detail significantly better. DVD builds are still done in DVD Studio Pro, 6 years old and going strong.
    And there you go.. a typical job can round trip through 6 - 7 programs quite happily. And the thing I'm loving about the Adobe suite is I injest the shoot content and then render out the final delivery and that's basically it.. no data ballooning in post, no transcoding, no render versioning, no writing out to export, and all largely non-destructive. Compared to the previous FCP/AE workflow I estimate I'm saving about 2.5x the drive space I used to use by having to transcode to Prores first. Makes me happy, makes my tape backup library happy, makes my relaxed server drives happy.
    Anyone have any workflow variations, tricks or time savers they'd like to share?

  • After installing OS X Mavericks, my cursor has been not working, by not even having a triangle cursor, just a set of lines, that expand across the whole screen when it goes over a random thing! Working on and off and getting worse, what should I do ?

    please help, need suggestions

    Hi sean981024,
    Thanks for visiting Apple Support Communities.
    If your cursor isn't working as expected, there are a few steps that can help isolate or resolve the issue.
    First, try booting your computer into safe mode:
    Mac OS X: What is Safe Boot, Safe Mode?
    http://support.apple.com/kb/ht1564
    If the cursor is working normally in safe mode, this usually means OS X is fine, and the issue is caused by conflicting software in your user account.
    Next, see if Finder behaves normally in a new user account. The steps in this article also apply to creating a new user in Mavericks:
    OS X Mountain Lion: Create a new user account
    http://support.apple.com/kb/PH11468
    If the issue persists in safe mode and a new user, I would recommend reinstalling Mavericks:
    OS X Mavericks: Reinstall OS X
    http://support.apple.com/kb/PH13871
    Best Regards,
    Jeremy

  • Embedded Flash players take control of the keyboard so that I can't use Firefox shortcuts; in IE I can tab across the whole page incuding the plug-in, but not Firefox; is there a way around this?

    See question.

    Hehe thanks for that, but I'm coming at this from the angle of not having a mouse to do that. I realise the obvious answer then is to plug one in, but I'm hoping there's another, keyboard-based way to do this.
    In IE, the Flash player is considered a part of the page like any other, and pressing Tab a few times to cycle through all the Flash buttons will then return you to the rest of the page - is there no similar method in Firefox?

  • Failed retrieval of the session object from the portal server in the WebApp

    hello out there,
    i tried to realize a multipartform file upload with a jsp-Channel (in .../portal/dt ) which sends the data into the same WebApp ( .../portal/ )to a different jsp-File but which is not using the desktopServlet of the potal. The Information where the file must be stored is generated in the jsp-Channel of the portalDesktop and saved in a session object. the problem i have is this: the session object generated in the jsp-Channel isn`t available outside .../portal/dt. But the WebAppContext is .../portal/ and the jsp File which processes the upload resides in .../portal/fileProcess.jsp . Does the PortalServer manage SessionManagement in a different way than an ordinary servlet/jsp container ?? if yes, how can i create a session object for the whole webAppContext ".../portal/ " ??
    i am very thankful for answers
    sincerely
    martin

    you may try to set usehttpsession to true in ../SUNWam/lib/AMConfig.properties file (restart after change). But using httpsession in portal is not an optimal solution for performance - performance tuning in production environment sets the value to false. I remember there is a good posting here about using session in portal, you may want to find it out.
    Hope this helps.
    Joe Zhou

  • Copy and Paste Stops working across the Mac OS X

    Recently I have been using my machine to connect to Windows XP machines using the RDC program (Mac equivilant of mstsc.exe) that Mircosoft provides.
    Whilst swtiching between applications on the host OS (Mac OS X 10.8) I found that my copy and paste functionaility across the whole OS appeared to stop working. A restart of the whole OS seem to resolve the problem, but when I dug a little deeper I found that it appears that once I terminated the RDC program the copy and paste functionailty came back. This also include any extented copy and paste functions within the Mac OS X eg, screenshots (cmd+ctrl+shift+3) and partial screenshots (cmd+ctrl+shift+4 very cool use it all the time).
    I just thought I'd add this issue to the Support forums in case other came across this problem, just one of those gotachas worth noting.
    Cheers
    Steve

    My keyboard stopped working and I recently installed a RDC program also.  I will try to uninstall it and see if that is the main source of the issue.   I will report back my findings for everyone else..

  • Lines across the screen

    I have noticed for the first time today (after I have been working on my iMac for a long time) that there are horizontal lines across the whole screen from the top to the bottom. First I thought they would only be on the picture of my desktop background, but then I opened iPhoto and saw the lines on every picture I opened. So those lines are there on the screen and and not only on the displayed image. Really annoying!!!
    Unfortunately my iMac is not under guarantee anymore...

    I have this too! I just bought this iMac a few months back. These screen are having a lot of troubles from what I am reading. My horizontal lines are not that bad, but you can notice them.
    I might sell these computer off quick as apparently the quality of these screens is a nightmare.

  • How do I fix my macbook pro from displaying the wrong dates across the entire system?

    Hello, for a while now my MacBook Pro has started to display the dates across the whole system weidly. The dates can go above 300/MM/YYYY. Is it the PRAM battery that could have run out or is it something else? Here is an example that I took today in the Calander application. As you can see it displays the 17 May, 2013 as 137 May 2013.
    If there is a solution for this i would really want to know because this is starting to anoy me a little.
    Here is an other example from skype
    Edit: Ironicaly I found the solution right after posting this, no help is needed any more. Everything is fixed now

    Have you looked at System Preferences>Date & Time?
    Ciao.

Maybe you are looking for

  • Passing a table into a procedure to be used in a curor

    Hi, I'm using Oracle 9.2.0.6 I have a procedure that searches all objects for a passed in string value. The procedure is below. CREATE OR REPLACE PROCEDURE Find_String ( pin_referenced_name IN dba_dependencies.referenced_name%TYPE) IS cursor cur_get_

  • How to get all menu items list in blackberry curve phone

    Hai all i am new to Blackberry application developer. I done one application in blackberry in default simulaor, I changed my simulator to Blackberry 8900 simulator. The features is more in curve phones like instant messaging. So i need to get the ful

  • Functional Clarification

    Hi All, Can anybody clarify me functionally(achivement) for the following reports, 1.Vendor wise Reports for Purchase Orders/ Goods Receipt Number Overview. 2.Comparison for Vendor wise contribution reports 3.Top Selling reports and Non moving item r

  • EP About top level navigation

    We are designing that many roles are assigned to one user. (about 7-8 roles per user) When many roles are assigned to the user, tabs in top level navigation bar can not be displayed without scroll horizontally. We want to display all roles at once, w

  • Designing Line Graph

    Hi, How to get class file to design a line graph with multiple series and facility to set minimum and maximum values of y-axis. and I need applet code also