MosheCh MosheCh -4 years ago 152
Java Question

Passing Object Parameter To Main Function Java

I have objects that look like this:


And I want to pass them to my java program as arguments and keep the connection between them.

If I could do something like that:

public static void main(Object[] args){

It could solve my problem but I can't so I thought about this solution:

Argument one:"1,2"

Argument two:"john,david"

Argument three:"15,40"

Then, split each Arg by ','
And keep the relationship between them by the place in the array

I don't like this solution.

Do you know better solution for this problem?

Answer Source

The static void main method is the starting point of every java application.

public static void main(String[] args){

if you modify that signature, the application never find a start point to be executed...

the most you can do is pass a string

the signature can not be modified to this

public static void main(Object[] args){

it must be always

public static void main(String[] args){

so you still have one shot, put this:


in a text File and pass the Path as string to the app so it can be found

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download