Solved

program vs VM arguments

Posted on 2014-01-31
6
346 Views
Last Modified: 2014-02-03
Hi,

i am looking into below program.

As in the screenshot

http://www.avajava.com/tutorials/lessons/how-do-i-set-system-properties.html?page=2

VM arguments author passing
-Dfavorite.day=Saturday -Dfavorite.car="Nissan 350Z"


My question can i pass them instead of VM arguments as program arguments text box(the one above VM arguments)
What are advantages, disadvantages of each of them.
please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 39825224
Yes, you can pass them as program arguments.  
To read them you would use something like  
String  favoriteDay  = args[0];
String favoriteCar  = args[1];    
that is purposeof args[] in the line  
      public static void main(String[] args) {
0
 
LVL 7

Author Comment

by:gudii9
ID: 39825263
What are differneces, advantages, disadvantages of VM and System Arguments
0
 
LVL 27

Expert Comment

by:rrz
ID: 39825307
I guess you read in the same web site  
http://www.avajava.com/tutorials/lessons/whats-the-difference-between-program-arguments-and-vm-arguments.html        
System arguments apply to the system.
Program arguments apply to your specific program.  
It all depends on what you trying to do.    
Hopefully an expert will have some more to say about it.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Assisted Solution

by:Mahesh Bhutkar
Mahesh Bhutkar earned 150 total points
ID: 39828872
Program arguments are arguments passed to your program and available in the args array of your main method.
public static void main(String[] args)

VM arguments are passed to the virtual machine. They can be accessed by program via a call to System.getProperty().
0
 
LVL 7

Author Comment

by:gudii9
ID: 39829839
which one is preferred to use in which case. please advise. why do we need to pass to virtual machine.what is the use case / practical use for that.
0
 
LVL 27

Accepted Solution

by:
rrz earned 350 total points
ID: 39829965
>which one is preferred to use in which case    
In the code you linked to at the top, it is a  kind of  a misuse to set system properties for parameters that will be used in just one class.
The Java platform itself uses a Properties object to maintain its own configuration. The System class maintains a Properties object that describes the configuration of the current working environment. System properties include information about the current user, the current version of the Java runtime, and the character used to separate components of a file path name.
that is a quote from  
http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html  
On that page, you can see commonly used system properties.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now