Denis Spirin

Ranch Hand
+ Follow
since Mar 22, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Denis Spirin

I understand form that I must have an executable jar.
My instruction doesn't state anything about .class files, but how can I execute the jar without calss files? Also, how about stubs , I genereate the stubs using rmic compiler, and I leave in the bin directory.


Your jar must include only .class files (not source files) and stub(s)/skeleton(s).


I tried to add the full path of the main class file, and it didn't work.
I tried to add the class name in the manifest using:
Name: suncertify.bin.Runme.class
and still didn't work.
It works only if I generate the jar file while I am in the bin directory, I don't know what else to do.


Check out all your steps again. Name must not include ".class", it should look like "suncertify.bin.Runme".
Are your files in corresponding packages (suncertify.bin etc)? Check if mf file is in plain text format.

Does this mean that if my assigment is accepted and i fail the essay exam, all i have to do is resubmit my assignment? If the assignment is accepted I can skip the essay exam on the second go-around?



You cannot fail essay exam, you write it only once. If you fail you need to correct your code and resubmit it.


I created the manifes.mf file. which contains
Manifest-Version: 1.0
Main-Class: Runme

my directory structure is:
suncertify>bin //has all classes
suncertify>code //has the source files
suncertify>manifest.mf // the manifest file

C:\dev>jar cmf suncertify/manifest.mf runme.jar suncertify*

when I run it I got class not found error.
C:\dev>java -jar runme.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Runme

Runme.class is in the default package:
suncertify/code/Runme.java
suncertify/bin/Runme.class



Hanna, first of all, do you have to include source files into executable jar? I dont know about B&S, but in URLyBird it is required to include only code.
As to packaging, I will simply explain how I did and you'll see whats the problem:
1. I have such file structure:
suncertify
|____ db___ files
|____client___files / contains file Start.class
|____server___ files
2. In root folder (one which contains suncertify) i placed mf.mf:

Manifest-Version: 1.0
Main-Class: suncertify.client.Start // <--- full path

3. Then I type:

$ jar cmf mf.mf runme.jar suncertify

4. Now java -jar runme.jar must work.

[ June 09, 2004: Message edited by: Denis Spirin ]
[ June 09, 2004: Message edited by: Denis Spirin ]
I think you can find the answer in your instructions.html:

You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server.

(Server-side) booking method looked like this:




In lock manager I used standard lock(), unlock() (wait() until notified if record is booked, etc) with HashMap holding ID-recNo pairs, but as ID i used object returned by Thread.currentThread().
Thus we have no deadlocks (due to dead clients) and increase of performance because there is no need to pass cookie to client. However, both lock and unlock must be called from the same method because only then it is guaranteed that client id wont change.
[ June 07, 2004: Message edited by: Denis Spirin ]

Wow, you are amongst the minority of people who cleared SCBCD w/o HF EJB.



Thats why I got only 82%
20 years ago
IMHO static counter ensures that there will be no same cookies. But I didnt use cookies at all and cannot tell which way is better.
[ June 07, 2004: Message edited by: Denis Spirin ]

I'm going to use RMI - so you mean the Data class would need to be bound?



I thought you were talking about DataManager class. Sure, there must be only one instance of Data class, but all you need is just declare it as static in corresponding class which would extend UnicastRemoteObject class. But when you bind some class to registry, only one instance of it will be served to clients (while client requests will be processed by multiple threads).

I'm using a private static vector to hold the record Id's of locked bookings.



Therefore, private static vector will not be thread-safe (as any static field). You shopuld ask yourself: what would happen if 2 (or more) threads would try to book the same record. Even if you use thread-safe collection, it does not ensure that there is no client collision. There are few ways to implement locking, most common is to create LockManager class (which must be singleton) with lock and unlock methods, which will take care of multiple threads by using wait and notify(All). You should search forum to find out how people implemented it.
Hi Arun


It took about a month to prepare for SCBCD. I used:
1. Specs.
2. http://java.boot.by/bcd-guide/
3. Mock exams on jdiscuss.com, ejbcertificate.com.

As to SCJD, I read book by Alain Trottier (although my advice is to use some other book) and got great help on JavaRanch
Programming/documentation/testing took about three weeks.
20 years ago


When a new client connects the server doles out the Bookings held in the list. Each GUI will have its own Data class, but I thought of making the DataManager a singleton and let it deal with reading/writing and maintaining the list of Bookings. The DataManager will be created when the first client connects.



As I understand, you use socket networking? For RMI such object should be bound to registry before any client connects.

Can anyone tell me if they see anything wrong in this approach??



Sure, there must be only one such object if you use sockets. How do you lock records by the way?
Suppose you want to switch database. Admin can press button "change database" and choose it (JFileChooser). Once he has chosen db file, server calls corresponding method on your RemoteDatabaseImpl (your class which extends UnicastRemoteObject) and passes file name. This method
1. blocks entire db and read access
2. reads data from file
But there is the problem - how to let users know that db file has changed?
1. Kick off all users which are trying to book record
2. Call method to make them to refresh their data. Use RMI callback. http://www.ryerson.ca/~dgrimsha/courses/cps841/RMICallbacks.html
You should use System.getProperty("file.separator"), thats all.
I still cant get it. What do you mean by saying "restart"? If you want to change datatbase file the server serves to client, then you need to put some 'switch' in corresponding class and add button to GUI, so that admin could call some method to chande db file. However you will also need locking on case if client was doing something with db while another file was opened.
It would be good for real program, but for scjd youre not REQUIRED to do that. You will get NO EXTRA POINTS for that, you may only LOSE points if examiner will find a bug or simply will not like code.
But why do you need that ? Whats the reason to restart server? If you mean that admin may want to choose another database file and restart with that file, then he can just restart program. Why do you want to keep it in the same thread?