Meaningless Drivel is fun!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird: runme.jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBird: runme.jar" Watch "URLyBird: runme.jar" New topic
Author

URLyBird: runme.jar

tom smith
Greenhorn

Joined: Feb 16, 2006
Posts: 20
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?
B Chen
Ranch Hand

Joined: Dec 27, 2005
Posts: 89
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 ]

SCJD<br />SCJP 1.4
tom smith
Greenhorn

Joined: Feb 16, 2006
Posts: 20
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 ]
Jimmy Persson
Greenhorn

Joined: Feb 19, 2006
Posts: 8
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

Joined: Feb 16, 2006
Posts: 20
.... 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!

Kristof Janssens
Greenhorn

Joined: Jan 05, 2005
Posts: 23
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.


SCJP 1.4 (90%)<br />SCJD (in progress)
tom smith
Greenhorn

Joined: Feb 16, 2006
Posts: 20
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 ]
Tomasz Luchowski
Greenhorn

Joined: Sep 16, 2004
Posts: 15
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


Tomasz Luchowski<br />SCJP, SCBCD, SCWCD, SCEA part 1
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
i agree with tomasz


-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLyBird: runme.jar
 
Similar Threads
Executable Jar File
Bodgitt and Scarper jar file
Packaging assignment jar...
assignment JAR problem
kill executable jar ?