Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VM arguments in eclipse

Posted on 2014-03-06
1
Medium Priority
?
1,586 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 36

Accepted Solution

by:
mccarl earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

824 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