Two Laptop Bag*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes packaging final application 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 "packaging final application" Watch "packaging final application" New topic
Author

packaging final application

Pankaja Bansal
Greenhorn

Joined: Feb 16, 2006
Posts: 19
Woof... Finally, I think I've completed my application development part. I am working on the testing and documentation now and one thing I can't figure out now is packaging.


All elements of your submission must be packaged in a single JAR file. The JAR file must have the following layout and contents in its root:
The executable JAR containing the programs. This must be called runme.jar.
The original, unchanged database file that was supplied to you. Note that you must keep a copy of the original database file supplied to you, and this must be the file you submit. The marking process will expect the exact same data without any changes.
A directory called code, containing all the source code and related parts of your project. You must create subdirectories within this to reflect your package structure and distribute your source files within those directories.
A file called version.txt. This must contain pure ASCII (not a word processor format) indicating the exact version of JDK you used, and the host platform you worked on.
A directory called docs, containing the following items at the top level:


The specs say that all executable should be in a jar file. Now I have two executables one for server and one for client, and as far as my knowledge goes, there can be only one main class in one jar file. so how are we supposed to package the two executable programs in one jar. ??

Also, could someone please let me know the command for creating an executable jar file. The way I am doing seems to give me some problems..

Thanks a lot...

Cheers
PB
Matthew West
Greenhorn

Joined: Mar 12, 2006
Posts: 2
Hi Pankaja,

I don't know what assignment you got, but mine clearly states that there is only ONE executable, and therefore one Main-Class. When you look at the assignment, it says supply a flag indicating server, stand-alone or client. Whereas the client-flag is supplying no flag at all.

You should read your assignment thorougly again, to avoid automatic failures.
Good luck.
Ed Tse
Ranch Hand

Joined: Sep 18, 2003
Posts: 183
I believe it's a jar inside a jar. Your program jar contains the binary, the submittion jar contains your program jar, docs, choice.txt, etc.


SCJP, Pre-SCJD (URLyBird 1.3.1), Teradata Cert'd Prof
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
Pankaja - your instructions probably also tell you exactly what command line MUST be used to run the application in standalone, server or client mode. In my case the modes were distinguished by a single commandline option - i.e. java -jar runme.jar server or java -jar runme.jar client.

You just have to arrange for the main method to run the appropriate part of your application based on the command line argument.

To create an executable jar file, you need to supply a manifest file to the jar command. Personally, I used ant for all my compiling and building as well as assembling the final jar file.

Good luck!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Pankaja,

If it helps, we created a visual depiction of the "jar-within-a-jar" concept in our book:



So for our example application you would have a "deliverable jar", and in the root of that, you will find the "executable jar", the database, the "doc directory" and the "src directory". Very similar to the real assignment.

Does that help?

Regarding having a command line to create an executable jar file - perhaps you could post the command line you are currently using, and we will make comments / suggestions on it.

Regarding the requirement of having one executable that can start both server and client, whereas you have seperate executables for server and client, all you need do is create a facade that will start the correct application for you. For example, if you currently have a class named suncertify.gui.Server to start your server, you could create a wrapper class that does something like:Of course, you would probably want to check that you do have an args[0] before trying to use it in the comparison, and you would have to add in the correct checks for the client side as well.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Matthew,

Welcome to JavaRanch and this forum.

We don't have many rules around here, but one we do have is the JavaRanch Official policy on registered names which requires (amongst other things) users to "use a real name as their display name, with a first and last name, and maybe more, separated by spaces." Could you please take a look at that policy, then change your displayed name to suit it? You can change your displayed name here.

Thanks,

Andrew
Pankaja Bansal
Greenhorn

Joined: Feb 16, 2006
Posts: 19
Hi everybody.

Thanks a tonne for your prompt and very helpful replies. Andrew, your description was an eye opener. I realized the mistake I was doing. I was thinking that the mode parameters "server" or "alone" indicates whether the clients need to connect to server or run in standalone mode.

This is the part of my specs that mentions the requirement.

The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.


What I understood now, is "server" indicates starting the server. "alone" means it doesn't matter if server is on or not, but client should start in standalone mode. Where as no parameter expects that server is on and starts the client in network mode connecting to the server. If however in this mode, the server is not on, it should throw an error. Please let me know if I am correct this time.

Once again, thanks all of you for saving me from making a blunder.

Regarding making an executable jar file, I think, I would use ant to do the job as it will be a new learning for me.

Regards
PB
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Pankaja,
What I understood now, is "server" indicates starting the server. "alone" means it doesn't matter if server is on or not, but client should start in standalone mode. Where as no parameter expects that server is on and starts the client in network mode connecting to the server. If however in this mode, the server is not on, it should throw an error.
Sounds good to me.
Regarding making an executable jar file, I think, I would use ant to do the job as it will be a new learning for me.
While using the assignment to learn tools like ant (and remote debugging and ...) is a great idea, I would still recommend doing it manually at least once. That way you know what the end result should look like. If you go straight to using ant and then end result doesnt work you wont know whether it was a problem with your ant script or a problem with your executable jar file concepts.

Regards, Andrew
Matthew West
Greenhorn

Joined: Mar 12, 2006
Posts: 2
Originally posted by Andrew Monkhouse:
Hi Matthew,

Welcome to JavaRanch and this forum.
... *snap* ...
Thanks,

Andrew


Hi Andrew, after reading several topics it occured to me that I had removed my last name. I corrected it accordingly, thanks for notifying.
[ March 15, 2006: Message edited by: Matthew West ]
tom smith
Greenhorn

Joined: Feb 16, 2006
Posts: 20
Andrew, thx for your previous reply. This is the question I have had:



if the parameter "server", then how do we launch the client app once we load the server code as we do above where "server".equals(args[0]).

--

Reading the later posts:

So, if the user wants to work in network mode he will need to open the client via a separate command line?

That appears to be. I was thinking there was a way for the RMIServer main() to call the client main() somehow.
[ March 21, 2006: Message edited by: tom smith ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Tom,

I think you answered your own question, but just to confirm:
So, if the user wants to work in network mode he will need to open the client via a separate command line?
Yep.
That appears to be. I was thinking there was a way for the RMIServer main() to call the client main() somehow.
Well you might be able to do this, but what would be the point? If you did this you would only have one client connected, which defeats the purpose of having a client-server system.

Having each client start from their own command line means that you can have any number of clients connecting to the server (which is also running from it's own command line).

The instructions also hint that the various applications might be running from within their own directories as well, since the saved parameters must be stored in the current working directory - this would make no sense if the client(s) were being started by the server since they would then all have the same current working directory.

Regards, Andrew
tom smith
Greenhorn

Joined: Feb 16, 2006
Posts: 20
andrew:

if we use an adapter class (with main()) can we just do like:

psuedocode:



Someone else had suggested this and I think it works. But I threw in some "shout outs" (I need to start Logging) from the RemoteDatabase code and there was no reply.

I am confused because given my current code, my Client in the 'else' above can only connect via rmi://localhost:1099/DataServer.

Just wondering where / why there was no 'reply' from the RMIDatabase? This leads me to believe the Client is NOT connected to the remote Database.

[ March 25, 2006: Message edited by: tom smith ]

[Andrew: Put psuedo-code between [code] and [/code] UBB tags.]
[ March 25, 2006: Message edited by: Andrew Monkhouse ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Tom,

In your psuedo-code, you show that you are starting a client immediately after starting the server - is this is a typo? Was the sample code meant to be as follows?If you did intend to start a client at the same time you start the server, how are you justifying this? According to my instructions, “the server program must run [if] the mode flag [is] "server"” - to me this does not imply that a client application must also run. I am not saying it is wrong to start a client application, just curious about the justification for it.

When you call new RMIServer(port, path, host);, where are the parameters for "port", "path", and "host" coming from?

Regards, Andrew
 
wood burning stoves
 
subject: packaging final application
 
Similar Threads
NX:What is the name of uploaded jar file?
question about userguide.html
What the final jar file structure should loook like?
runme.jar file confusion
Readme.txt