to access the .properties during development on Linux

I have a program that normally runs as a package of .jar. There are several files of property, and everything works well, regardless of the OS.

During development I sometimes run the main class directly. The properties files in the current directory. Everything still work correctly in Windows.

However, under Ubuntu Linux, the file properties are not. It is configured to print a message to the console, and is an example of message:
loadProperties(): cannot access cnd_ntc.properties
it seems to search for the properties at the level of the root directory structure. What is the way of cross-platform to access the property files that will work within a .jar file and without?

File names are added with a "/" (for example "/ CNDfilelist.properties"), which I thought was the appropriate way to do so.

For reference, here's the method I use to open all the .properties files:
    // encapsulate opening of a properties file.  returns null if problem
    public static Properties loadProperties(String file)
    {
        String me = new String("loadProperties(): ");
        if (file == null) {
            System.out.println(me + "null filename");
            return(null);
        }

        Properties p = new Properties();
        InputStream fis;

        fis = NTC.class.getResourceAsStream(file);
        if (fis == null) {
            System.out.println(me + "cannot access " + file);
            return(null);
        }

        try {
            p.load(fis);
        } catch (IOException e) {
            System.out.println(me + "cannot load " + file);
            try {
                fis.close();
            } catch (IOException e2) { /* what the heck you gonna do? */ }
            return(null);
        }
        try {
            fis.close();
        } catch (IOException e) { /* what the heck you gonna do? */ }

        return(p);
    }
-Rich

You have a CLASSPATH environment variable in Linux? If Yes, what is it?

Tags: Java

Similar Questions

  • Want to access the text file of ODI linux machine installed on windows

    Hi all

    I want to access the text file of ODI linux machine installed on windows computers.
    To do this, I created the server data files (physical schema) and;

    Host(Data Sever): IP address of the linux machine
    User: user of linux machine name
    Password: data

    Directory: / hyperian/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1 / * application *.
    I shared the folder app in linux machine.
    When you try to run the interface using this file inside the folder app, its giving below error


    7000: null: java.sql.SQLException: file not found: /hyperian/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1/app/STORAGE.csv
    java.sql.SQLException: file not found: / hyperian/Oracle/Middleware/user_projects/epmsystem1/EssbaseServer/essbaseserver1 /app/STORAGE.csv

    to com.sunopsis.jdbc.driver.file.x. < init > (x.java)

    at com.sunopsis.jdbc.driver.file.d.b.d.a (d.java)

    at com.sunopsis.jdbc.driver.file.g.a (g.java)

    at com.sunopsis.jdbc.driver.file.w.executeQuery (w.java)

    at com.sunopsis.sql.SnpsQuery.executeQuery (SnpsQuery.java)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders (SnpSessTaskSql.java)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt (SnpSessTaskSql.java)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt (SnpSessTaskSqlC.java)

    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask (SnpSessTaskSql.java)

    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep (SnpSessStep.java)

    at com.sunopsis.dwg.dbobj.SnpSession.treatSession (SnpSession.java)

    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand (DwgCommandSession.java)

    at com.sunopsis.dwg.cmd.DwgCommandBase.execute (DwgCommandBase.java)

    at com.sunopsis.dwg.cmd.e.k (e.java)

    at com.sunopsis.dwg.cmd.g.A (g.java)

    at com.sunopsis.dwg.cmd.e.run (e.java)

    at java.lang.Thread.run (unknown Source)


    One faces this question erlier? then helpme out.

    Hello

    1. If your files are located on a remote file system, you will need to copy one of your files to the computer that Designer ODI runs to allow ODI retrieve the metadata of the file information.
    2. in the topology to create a physical schema, the directory you enter data and the scheme of work must point to this local file.
    3. then set the file data store in the designer of the ODI. Enter a name, browse and select the file and fill each deposited the files tab.

    * If it's a fixed file, click on the network icon in the column into the columns tab and have checked auto adjustment.
    * If it is a delimited file, use the reverse button on the columns tab to reverse the columns.
    * Right-click on the Datastore folder select View Data, if you can view the data, which means that store file data has been correctly set.
    * If this is not the case, check each tab of the database file to make sure that everything is set correctly and try again.

    4. once the display data to be successful, now change you directories (data and the scheme of work in topology) to point to the remote file system. These directories must be accessible to the ODI Agent that will be used to perform transformations. The directory can be an absolute path (m:/public/data/files) or a parent in the ODI Agent startup directory (.. files/demo /). It is strongly recommended to use a UNC (regardless of the location of execution) name for the path. Executing transformations "agentless", the directory is relative to the directory where Oracle Data Integrator was installed.

    You must have an agent process running on the system that contains your source file.
    Then during the race, the odi interface choose this agent.

    Thank you
    Fati

  • Well confused. I use click on Favorites in the upper left corner of the screen. I can still but I can't access the properties of the bookmark

    I used to just right click on a bookmark of Bookmark menu in the upper left corner of the screen. Now when I right click on Favorites, I can't get any of the choice to highlight, they are subject, and nothing happens. But if I add bookmarks little star at the high right to help customize I can access an area of the one bookmark away. Seems that just suddenly happened. I like to use the left side of the screen, but cannot access the properties there. Any difficulty?

    Devil well, now, all is well, seems to set just after a reboot. So solved my problem all by my lonesome. Please disregard.

  • When I click on properties in my tab of connection area I can't access the properties settings.

    Connection impossible access area properties

    When I click on properties in my tab of connection area I can't access the properties settings. I need to change the settings of ip address of my connection to the local network on my laptop

    Hello fazlurslemming,
    1. may I know why you must change the setting of IP address on your laptop?
    2. are you able to connect to the internet?
    3. what version of windows are you using?

    Visit the below link to find the steps to change the IP address on a windows 7 installed system:
    http://Windows.Microsoft.com/en-us/Windows7/change-TCP-IP-settings
    Post back with the State.

  • access the properties of digital format

    I create digital controls/indicators on the fly.  Most of them should be displayed in hexadecimal.  However, I can't access the format properties that allow me to define that when I create the indicator/control using the new object VI VI.  I think that this happens because the numeric type is not digital (Strict) but rather just num.

    I say this because I realized that if I simply place a digital control on a façade, made a right click to create a reference, and then access the properties of the said reference, I have access to the properties of the format, I want to talk.  A compare/contrast below pic to show what I mean...

    So my thought then was, maybe I should change the style of the object I created to be digital digital type, but this style does not exist.  There are styles of digital data, but this is something completely different.

    So my question is, what style/class combo do I need to have a digital control that will allow me to specify the Format property?

    Thank you

    You need to do a digital Digital.

  • "Unknown error" whenever I try to access the properties of the network connection

    Hi all

    whenever I try to access the properties of a network connection (e.g. via right click on 'Network'-> properties-> right click on a connection-> properties), type of connection according to what is, I get a message "Unknown error" box and I can't move forward.

    As a result, any setting of any network connection is not editable, more. For example, I wanted to force the IP of the local network of "assigned to DHCP" to "static" with an address fixed IP, but I can't.

    Another weird thing is that I even can't delete one of the existing network connections, even if there are a couple that are not in use for a long time...

    It should be noted that, apart from that, the network of connections work.

    What can cause this behavior, and that might be the way to solve the problem?

    I want to upgrade the system to SP3 but I am reluctant to take the plunge with such an "alive"... error
    As you may have already guessed, the system is running XP SP2.

    Thanks in advance,

    Concerning

    Yes, I am facing the same problem too. The error message says "an unexpected error has occurred." This problem started out with me a few weeks back and I was under the assumption that it was due to a virus attack. But even after a thorough cleaning session problem continues to exist.

    The problem - as mentioned above by the Bell, we can neither open the properties of a connection (i.e. Dial-up/LAN/WLAN), or remove or add a new connection. If you try to open the connection properties, all you get is the message "an unexpected error has occurred" and if you try to delete or add a connection - the system does not respond!

    Surely, this link worked for me. I hope it works for you Bell. Check it out.

    http://wdbuc.com/blog/2010/02/03/an-unexpected-error-occurred-when-you-right-click-on-a-network-connection-in-Windows-XP/

  • I've just updated to LR 6.2.1 and now I cant access the subfolders during import subfolder, hope that they address

    I've just updated to LR 6.2.1 and now I cant access the subfolders during import subfolder, hope that they address

    Hi Crobadus,

    Yes, this will be fixed in the next update.

    Until then, you can go back to Lightroom 6.1.1 if you need to have the same workflow

    Instructions to restore an earlier version of update

    Kind regards

    Claes

  • Access the properties of the line in the script

    Hi Experts

    I need to access the properties 'De TIP' and 'Gap' in Javascript ID CS4. I research in the references of scripts, but I failed. I have undderstand this property can not be set in the object model.

    gap.JPG

    Any help is welcome.

    Thanks in advance

    Concerning

    Arul

    Hi Arul,

    Check strokeDashAndGap Style of object/object property.

    HTH.

    --

    Marijan (tomaxxi)

    http://tomaxxi.com

  • access the properties of a movie on the timeline

    I'm trying to buil a project that contains two clips and I need to access the clipA clipB period properties.

    If the parent property specifies a path to display objects that are above the current display to the screen object the list hierarchy, property that points to objects that are below?

    I m sure it must be easy to answer. I have just can´t seem to figure it out.

    Any help would be appreciated.

    I do not know how to interpret your description above / below, but to access the properties of clipA clipB, assuming that they share the same parent timeline...

    AS2: _parent.clipA.property

    AS3: MovieClip (this.parent).clipA.property

  • To access the properties of the controls from other mxml components

    Yet to learn Flex and if this question seems trival please bear with me.

    What I have to do is access the properties of a control in the file main mxlm, but the control is in a separate mxml file.

    The scenerio is that I have a checkbox in the chkbox.mxml file. I need to know the value of the selected property, so that it is accessible to me in the main mxml file where I use this property to determine how to navigate the application.

    Thank you

    Hmmm

    something like

    If (parentApplication.myCheckbox.selected == true) {}
    to do this
    }

    or even

    If (application. Application.myCheckbox.selected == true) {}
    to do this
    }

    does it work?

  • To access the properties of an Error Message When you use the DisplayRunTimeErrorDialogEx method

    I have a reminder that displays the standard runtime error dialog box using the method Engine.DisplayRunTimeErrorDialogEx of custom error. http://zone.ni.com/reference/en-XX/help/370052H-01/tsapiref/reftopics/engine_displayruntimeerrordial....  The parameters of this do not allow me to specify information about the error message available (via the properties of the stage of the appeal of error).  However, when built-in bed in treated TestStand display dialog runtime error through its methods of error handling he managed to fill in the details about the error.

    Anyone know how I can fill in the details and the error code from the dialog box fields when you use the DisplayRunTimeErrorDialogEx method to call it? See attached screenshot by one example of what I get when I use this method.

    Kind regards

    David

    Doug is correct; each sequence in the call stack has its own sequence context, so if you just "ThisContext" for the sequence context parameter, you provide the framework for the error callback, which has no error.  To access the context of the sequence that wrong, you use the caller property to get to the next level in the call stack, for example:

    RunState.Engine.DisplayRunTimeErrorDialogEx ("error Dialog", ThisContext.Caller, 0, False, False, False, False)

    I hope this clarifies!

  • to access the properties of the account of HFM of FDM

    Hi Experts,

    I need your help. I have a requirement in which I need to access account properties HFM of FDM.

    Can you please if there is a way/function/api through which I can access account properties of FDM dimesion HFM?

    Thanks in advance.

    What is FDM or FDMEE?

    In the classical FDM, the API adapter had functions to retrieve the properties of metadata HFM.

    In the classic FDMEE you create your own solution as using SQL queries to retrieve the properties you need, or by using the API of HFM

    Concerning

  • How can I access the properties in reader for mobile

    How can I access the drive properties in the mobile app?

    Hi robmorrison75,

    Unfortunately, it is not possible to display the properties of the fields on form or annotations in Acrobat Reader mobile apps (for iOS, Android, Windows Phone).

    Please use the version of desktop of Acrobat Pro to view and change the properties.

    Sorry for the inconvenience.

  • How to access the form during the treatment?

    Hello

    How you can access its form during the treatment of a certain task--like a query or run a report - in order to cancel or interrupt this process?...

    Thank you...

    To be able to interrupt a query, you can set the Mode 'Interaction' property at the level of the form.
    For any other interruption, you will need to program it one yourself.

  • Using 'this' - or not? To access the properties of a member of a class from the class.

    I have a class, call MyClass, and there are several variables that I need to be able to access each instance from within the class.

    For example, if I need the myObject1, a member of the MyClass object, to store the variable myNumber.

    Since the main scenario, if I draw myObject1.myNumber, I get whatever number I have stored.

    However, I need to check the numbers against another parameter, so I need to test if myObject.myNumber is myOtherNumber. But within the class, if I trace this.myNumber or myNumber I get null.

    What is the proper syntax to access a variable in a class?

    looking for a matter of time, wherever you are trying to access the variable in your class before it is defined (in the main timeline).  the following is a typical mistake:

    var yc:YourClass = new YourClass;

    YC.var1 = "Hi";

    ///////////

    package {}

    import...

    public class YourClass...

    .

    public void YourClass {}

    any attempt to access this.var1 here (the manufacturer) will fail

    }

    }

    }

Maybe you are looking for

  • Irritations iOS 10.0.1

    Long time iOS user, first time poster. For the first time in a while I really look forward to the latest version of iOS, but after having upgraded, I find myself irritated by the latter. -Notifications Is no longer, I can drag up to dismiss a notific

  • question about obtaining a specific version of the Skype client

    Hello world I was using Skype on my desktop for a few months with the version number 7.26.64.101. It works very well for me and I can't remember where I downloaded this version. This morning, I did an upgrade of the manual system of my office, and it

  • Must photo images be stored in the iCloud?

    I just bought a new iMac... replace my old duo core intel 20 "... and my situation is that my internet connection is a satellite which has a limited monthly data plan.  There is no downloading easy and seamless with my modem and some interruption buf

  • (Redirected) Alienware M17x (R1) battery_where to buy?

    I bring my m17x relive (I hope). Any place that I could always get a battery for a?

  • Fixed width site - Mobile breakpoint is not in line with the size of the screen

    Hi allMuse Noob here. Still having problems with a Web siteBefore I made this site fixed width with no break points and would be automatically to down-size to fit the smaller screen sizes such as phones etc. Now, I've added a breakpoint of fixed widt