?
Solved

passing argument to java program

Posted on 2004-03-30
7
Medium Priority
?
337 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
[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
  • 4
  • 3
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 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