Solved

Reading paramters passed to JVM

Posted on 2007-12-05
3
740 Views
Last Modified: 2008-02-01
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 ?
0
Comment
Question by:apparition
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20416120
String property = System.getProperty("prop.dir");
0
 
LVL 5

Author Comment

by:apparition
ID: 20416183
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"



0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 20416242
> -Dconfig.dir = "aasda"

should be:

-Dconfig.dir=aasda
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse digits of a number using for loop 5 40
tomcat not starting 6 45
use lov values 2 49
Running JavaFX on JDeveloper 12C 1 31
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question