Solved

VM arguments in eclipse

Posted on 2014-03-06
1
1,277 Views
Last Modified: 2014-03-25
Hi,

My test1JUnit.java has below entry


       final String testFileName = System.getProperty("project.basedir") + "\\src\\main\\resources\\temp\\test.txt";


In order for me make junit to work i have to go to junit run configuration --->arguments--->VM arguments the add

-Dproject.basedir=C:\\TestPOC\\current\\TestPOC


Then it all worked.

test1JUnit.java has is calling TestService.java which also has entry

       final String testFileName = System.getProperty("project.basedir") + "\\src\\main\\resources\\temp\\test.txt";


so fixing below took care inside TestService.java also.
"i have to go to junit run configuration --->arguments--->VM arguments the add

-Dproject.basedir=C:\\TestPOC\\current\\TestPOC"



My question is

"i have to go to junit run configuration --->arguments--->VM arguments the add

-Dproject.basedir=C:\\TestPOC\\current\\TestPOC"

Doing above step is not only fixed for junit test class but also TestService class also?

What is meaning of the VM argument how it fixed in both places?


please advise
Any links resources ideas highly appreciated. Thanks in advance
CAn we send different environment property files(dev, qa, prod) using the arguments for maven build?
0
Comment
Question by:gudii9
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39911391
It fixed for both because as you said, test1JUint.java is calling TestService.java, and so therefore the code in both are running in the same JVM. And system properties are defined across the entire JVM and so that property can be accessed from both location that you are asking about.

Generally speaking, to support different environments (such as dev, qa, and prod) you can use a feature of Maven known as Profiles. Firstly have a read of this...

http://maven.apache.org/guides/introduction/introduction-to-profiles.html

... and if this looks like what you are after, I can help/guide you further.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

831 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