Link to home
Start Free TrialLog in
Avatar of apparition
apparition

asked on

Reading paramters passed to JVM

I would like to pass a paramter into the JVM and have my code read it. So for example on the start up script for my app server I would pass a paramter like -Dprop.dir="some/dir". How would I go about doing something like this ?
Avatar of Mick Barry
Mick Barry
Flag of Australia image

String property = System.getProperty("prop.dir");
Avatar of apparition
apparition

ASKER

I tried this in eclipse but get an erro
java.lang.NoClassDefFoundError: =
Exception in thread "main"

here is the code
public class ReadParam {

      /**
       * @param args
       */
      public static void main(String[] args) {
            String home = System.getProperty("config.dir");
            
            System.out.println(home);

      }

}
When I run it I pass the following parameters in eclipse VM parameter box
-Dconfig.dir = "aasda"



ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial