facebook

environment variable

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #261528 Reply

    David
    Member

    On OS X, JBoss4.0.2, mySQL:

    I have an EAR file that I build using and ANT script, then manually copy into my jboss/server/default/deploy directory. I have an environment variable that I normally will set with a bash script. However, I am starting/stopping this in development using the myEclipse JBoss 4 icon. I am trying to find where to set this property so that it gets read when JBoss. I have tried setting it as a JBoss Launch configuration, but it doesn’t stick. When I go back to check on it, its gone and the application can’t find the value either.

    What is the best way to set this so my application sees it?

    #261550

    Riyad Kalla
    Member

    When you say an environment variable, do you mean something like:

    
    export SOME_VAR=/usr/local/lib
    

    or do you mean a Java system variable that you can get with something like:

    
    String property = System.getProperty("SOME_VAR");
    
    #261718

    David
    Member

    Sorry, I should have explained better.

    Here is my *partial* script that sets the variable before starting JBoss in production:
    JBOSS_HOME=${PROJECT_BASEDIR}
    PROJECT_PROPERTY_FILE=${PROJECT_BASEDIR}/properties/project.properties

    export PROJECT_PROPERTY_FILE

    According the propertary class notes, this is coupled to the environment.

    And here is how it is used in the code:
    private static final String PROPERTY_FILE_KEY = “project.property.file”;
    String filename = System.getProperty(PROPERTY_FILE_KEY);

    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filename));
    // load the project properties into the new properties object
    _nprops.load(bis); <== proprietary class I don’t have source for
    _nprops.putAll(System.getProperties());

    So I can either try to rewrite existing functionality with my own sort of map, or I can set the property environment variable so Eclipse picks it up. Like I said, this works already in production, but in trying to run it inside of MyEclipse I can’t seem to set this.

    #261720

    Riyad Kalla
    Member

    Ahh, System.getProperty will pull any properties set with the -D command line argument, you can set that in the JDK preference panel under Optional Arguments, something like this:

    -DsomeProperty=SomeValue

    then you can get it with:
    System.getProperty(“someProperty”);

    #261722

    David
    Member

    Thank you, I should have known it was there, I figured it changed because it was an IDE. I added the “-D” arguments to the Window|Preferences|Java|JDK and that did the trick!

    #261729

    Riyad Kalla
    Member

    Very cool, glad it did the trick.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: environment variable

You must be logged in to post in the forum log in