Solved

passing argument to java program

Posted on 2004-03-30
7
296 Views
Last Modified: 2010-03-31
i know we can pass the value to java program like:
java MyProgram Hello

Then in the MyProgram:
if ( args.length == 1 )
{
     String Greeting;
     Greeting = args[0];
}

but my problem how can i pass the address to my program? E.g. No 2, Street 132, 53000, Malaysia.

The java will treat each space is a new argument rite?

thanks
0
Comment
Question by:Kennywen
  • 4
  • 3
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 10720505
java MyProgram "No 2, Street 132, 53000, Malaysia"
0
 

Author Comment

by:Kennywen
ID: 10720525
>> java MyProgram "No 2, Street 132, 53000, Malaysia"

like this the java will treat it as 1 argument???

then if i write java MyProgram "I'm from" "No 2, Street 132, 53000, Malaysia"
then the java will treat it as 2 arguments???

thanks
0
 
LVL 92

Expert Comment

by:objects
ID: 10720540
yes and yes :)
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:Kennywen
ID: 10720561
if the command java MyProgram "I'm from" "No 2, Street 132, 53000, Malaysia" is not type in the console (command prompt) but is call by other program like C++ is't it will work too?

thanks
0
 
LVL 92

Expert Comment

by:objects
ID: 10720581
should do
0
 

Author Comment

by:Kennywen
ID: 10763459
sorry for late giving point.
0
 
LVL 92

Expert Comment

by:objects
ID: 10763494
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

808 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