File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes FBNS: JAR files and execution problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "FBNS: JAR files and execution problems" Watch "FBNS: JAR files and execution problems" New topic

FBNS: JAR files and execution problems

Gary Richards

Joined: Apr 12, 2004
Posts: 8
My FBN assignment is fairly close to handing in, so I thought i'd have a test run before checking though all my classes one last time to ensure i've not missed something stupidly. Anyhow, what I did was create three JAR files, FBNClient.jar, FBNServer.jar and FBNCommon.jar. Into the FBNClient I put simply the classes that were to produce my client. Into the FBNServer I put the class that started the server, and my rmi stubs. Into the Common I put everything else.
In the manifest for FBNClient.jar, I have:

When I do: java -jar FBNClient.jar
The client seems to work fine.
So, I pretty much mirrored this in the manifest for FBNServer.jar:

Then I ran into some problems. My server, which was working fine when I was executing it from the directory that the class compile too, it was working fine. I had a policy file that granted AllPermission. etc. I was doing the following:

What i'm doing now (and i'm not totally sure that it's correct is):

However, i'm getting the following:

Now, obviously according to this I don't have access to the C:\db.db file that I do have access too when i'm executing the server from its classes directory. And I have no idea why. Do I need to give my jar files permissions or something? Maybe their own copy of the policy file? Is my java.rmi.server.codebase incorrect now that the classes are in a jar file?
I'm really confused and don't know where i'm going wrong. Any help is greatly appreciated.
[Andrew: edited exception report so that horizontal scrolling is not required]
[ May 11, 2004: Message edited by: Andrew Monkhouse ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi Gary,
Why are you installing a security manager? It should not be necessary.
Does your policy file grant the permissions specified in the exception?
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Gary Richards

Joined: Apr 12, 2004
Posts: 8
Erm, probably from some kind of RMI tutorial i've followed in the past, I have in my code:

My policy file:

As I said, using this policy file and running the server from the classes directory, everything seems to work fine. After adding the files to a jar file, I get the exception described above and I have no idea what's wrong.
Ian Roberts
Ranch Hand

Joined: Aug 20, 2003
Posts: 46
Although in the FBNS assignment it does suggest the possible use of security manager (i.e. as part of the acceptable command line features) it is optional not mandatory. At least in my FBNS assignment.

I originally intended to use a security manager but, for the assignment, judged that this was an overkill and removed it. I explained my reasons for doing so in the Design Decisions documentation and I don't think that not using it had any effect upon my marking.

My understanding is that the new assignment details explicitly state not to use a security manager.
Hope this helps - I had similar fun while trying to use a security manager!
subject: FBNS: JAR files and execution problems
It's not a secret anymore!