• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

URLyBird: runme.jar

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The requirements state that there must be an executable jar called 'runme.jar'.

I figured out how to do this....

but I am correct in that only one 'Main-class' is allowed per manifest file.

Also, I tried appending command line arguments to this 'Main-class':



by it did not work.

The Networked mode obviously requires two processes. Is there a way to open two processes from one executable jar?

Perhaps the System.getRuntime() can be used to launch a separate process?

Or maybe there is way to launch a .bat file?
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The command-line arguments you put in the command-line when you execute the jar file. The manifest file specifies the main-class.
Then from the command-line you type one of the following:

java -jar runme.jar alone
java -jar runme.jar server
java -jar runme.jar

To run in client-server you do:
From one terminal you type, java -jar runme.jar server
From another terminal you type, java -jar runme.jar

To run in standalone mode, in the terminal you type, java -jar runme.jar alone

[ March 20, 2006: Message edited by: B Chen ]
[ March 20, 2006: Message edited by: B Chen ]
 
tom smith
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still dont see how to get it to work in networked mode.

If the manifest has one Main-Class, then runme.jar will open up the Client in whichever mode, server or alone. The client has it's own main().

But my RMI server in a separate class with it's own main().

If runme.jar jar can only have one Main-Class as specified in the manifest, then I would have to name the .jar file with Main-Class: suncert.db.RMIServer something other than runme.jar.

I am just stumped.
[ March 21, 2006: Message edited by: tom smith ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about one main.
Check which command line argument is passed when runme.jar is called and execute different code depending on that.
 
tom smith
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.... by 'execute different code' i am assuming you mean from main().

Say my manifest Main-Class: in runme.jar points to URLyBirdClient main(), how can I open RMIServer, which requires its own JVM, from my URLyBird main()?

I am seeing two separate command line for two separate JVM's. I did read about class loading. By the Requirements specifically say no class loading.

--

I think I wasted $250!

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're making it too difficult for yourself

I shall explain how I did it:

- I have a client class and a server class, they have public constructors. There is NO main method in neither one of them
- I have a class called StartUp that only has 1 method: main()

That main method read the parameters the user gave in during the "java -jar runme.jar" procedure

StartUp.main() looks at the flag:
- is it SERVER, a new server object is created
- is it ALONE, a new client object is created and will start immediatly in standalone mode (I pass true or false in the client constructor so it knows which mode to run)
- is it empty, a new client object is created and will show my connection panel, which allows the user to go in local or in network mode

So my the manifest in my jar points to the startup class ... and that's it, you're done.

If you start it up, it will start client or server, depending on the flag you give. So by default the client is started.
 
tom smith
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kristof - thx.



I am a finance guy trying to learn java. A whole new world.

I need to study design patterns and such. Just purchased the Head First Design Patterns.
[ March 21, 2006: Message edited by: tom smith ]
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kristof Janssens:

StartUp.main() looks at the flag:
[...]
- is it empty, a new client object is created and will show my connection panel, which allows the user to go in local or in network mode



I do not think this is correct. At least according to my specificiation, when no argument is specified the client needs to run in networked mode - you should not allow the networked/alone choice at this stage.

Cheers,
Tomasz
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i agree with tomasz
 
reply
    Bookmark Topic Watch Topic
  • New Topic