wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to create/run client.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 "How to create/run client.jar" Watch "How to create/run client.jar" New topic
Author

How to create/run client.jar

Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
I am having trouble creating ad runnning the client.jar. How should I get it right.
Here is my directory structure:-
c:\suncertify\client
All the client classes have package statement as :-
package suncertify.client;
I can run my client as :-
cd c:\suncertify\client
set classpath=c:\;
suncertify.client.FBNClient hostname portnumber
This is what I do to create jar file
Manifest file:-
Manifest-Version: 1.0
Created-By: 1.2.2 (Sun Microsystems Inc.)
Main-Class: suncertify.client.FBNClient
I create jar file as:-
cd \
<c:\> jar -cvfm client.jar suncertify\client\manifest.mf suncertify\client\*.class
Then I run it as :-
java -jar client.jar hostname portnumber
This gives me a nullpointer exception.
So what am I doing wrong??
Thanks.


Samual Harvey<br />SCJP2<br />SCJD2
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Hi Samuel,
normally NullPointerExceptions have nothing to do with the .jar file but with your code. Try to find out where the NullPointerException acutally occurrs.
When something is wrong with the .jar, you usually get exceptions like FileNotFound or Zip...
[ September 05, 2002: Message edited by: Mag Hoehme ]

Mag
Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
Initially when I was creating the jar file using the command:-
<c:>jar cvfm client.jar c:\suncertify\client\manifest.mf c:\suncertify\client\*.class
I was getting FileNotFoundException.
SO I changed c:\suncertify to suncertify\. But this started giving NullPOinterr...
But at the same time when I run the same using the class name directly it works. Why it does not gives me a Null Pointer exception there?
Thanks.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Samual,
Do you have your Main-Class set in the manifest? Once I created my jar files, I just used Enzip to reload the packages and left the mainfest directory alone. Any zip program will work.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
Yes it is working now. I tested on different machines. Also on JRE it works.
One question:-
Right now I am building jar file using all the client/server/db classes. What is the better way to distribute the files.
This is what I tried keeping db common in both client and server. But then the client complains about the stub file. I know there is a way to resolve the problem of stub file. I guess RMI allows the client to download the stub files from the server . I just dont remember how to do this.
Thanks.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Samual,

Right now I am building jar file using all the client/server/db classes. What is the better way to distribute the files.

That's what I did. Simple and no headaches or worrying if a stub is going to properly load.
Michael Morris
Samual Harvey
Ranch Hand

Joined: Aug 06, 2002
Posts: 119
Originally posted by Michael Morris:

That's what I did. Simple and no headaches or worrying if a stub is going to properly load.
Michael Morris

How many jar files did u created. I mean if you are keeping all the directories in one jar file then you don't need multiple jar files. Did u created one for server and one for client?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Samual,

... I mean if you are keeping all the directories in one jar file then you don't need multiple jar files.

Yes, but you can only have one main class per executable jar file. So you really need two jars: 1 client and 1 server.

Did u created one for server and one for client?

I had one for the client and one for the server. They were both placed in the submission jar.
Michael Morris
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create/run client.jar