Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading paramters passed to JVM

Posted on 2007-12-05
3
Medium Priority
?
747 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 total points
ID: 20416242
> -Dconfig.dir = "aasda"

should be:

-Dconfig.dir=aasda
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

730 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