JAVA RMI put make object and save it into Hashtable

I am making RMI program which is supposed to a "test" object called "pruefung" in an hashtable.  The program runs in class Called "PruefungsverwaltungsClient" and uses an Class called "Pruefung"  I am a little confused where I am supposed to have the Hashtable but I am supposed to make the object "Pruefung" in an method called PruefungAnlegen(Pruefung pruefung) throws RemoteException;  and save it in hashtable The interface is called PruefungsVerwaltung. I tried to save the object in Hashtable at the top of the Client Class "PruefungsverwaltungsClient" but my Eclipse always wants me to make the Variables Static.   My idea is to make a function inside the class Pruefung which saves it in Hashtable.  can someone help me make the object and save it in Hashtable please  but here is the code:

Class Pruefung:

public class Pruefung implements Serializable {

      String pruefungsName;
      String beginn;
      String ende;
      String ort;
      String pruefer;
    Student student;
    public Pruefung(String pruefungsName, String beginn, String ende, String ort, String pruefer)  {
    this.pruefungsName = pruefungsName;
    this.beginn = beginn;
    this.ende = ende;
    this.ort = ort;
    this.pruefer = pruefer;
   void setPruefungsName(String pruefungsName) {
   void setBeginn(String beginn) {
   void setEnde(String ende) {
   void setOrt(String ort) {
   void setPruefer(String pruefer) {
  public String getBeginn() {
        return beginn;
  public String getEnde() {
      return ende;
  public String getOrt() {
      return ort;
  public String getPruefer() {
      return pruefer;
  public String getPruefungsname() {
      return pruefungsName;

//this was the idea about the hashtable!!!!!!!!!!!!!!!!!!!!!!
  Hashtable Hash = new Hashtable(); //byr til Hashtable
  public boolean Add(Pruefung ny)  {
        String ID = ny.getPruefungsname();
              return false;
        else {
              return true;



Client class PruefungsVerwaltungsClient:

import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.util.Hashtable;

 * Created on 27.10.2004
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments

 * @author Valdimar1
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
public class PruefungsVerwaltungsClient  {
      //Eclipse always wants to make there variables Static :(
      public static String test = null;
      public  static String pruefungsName;
      public static String beginn = null;
      public static String ende = null;
      public static String ort = null;
       public static String pruefer = null;
      public static Pruefung p;
       public void pruefungAnlegen(Pruefung p) {
             p = new Pruefung(pruefungsName, beginn, ende, ort, pruefer);

             test = p.getOrt();


      public static void main(String[] args) {
            String registryServer = null;

            // determine name of registryServer where remote object is registered
            // use a Security Manager
            //String message = "Blank", webServer = "";

            BufferedReader br = new BufferedReader(new InputStreamReader(;  //opens up standard input
            if(System.getSecurityManager() == null) {
                                      System.setSecurityManager(new RMISecurityManager());
            if (args.length == 1) {
                        // get registryServer from command line arg
                        registryServer = args[0];
            else {
                        try {
                                    // use local host as registryServer
                                    System.out.println("Using local host as registryServer.");            
                                    registryServer = InetAddress.getLocalHost().getHostName();
                        catch ( ex) {
                                    System.out.println("Failed to determine name of local host.");

            PruefungsVerwaltung obj = null;
            try {

                  System.out.println("lookup PruefungsverwaltungServer on: " + registryServer);      
                  // perform lookup in rmiregistry on registryServer for remote
                  // object "Hello-Server"
                  // cast reference to remote interface Hello

                  obj = (PruefungsVerwaltung)Naming.lookup("//" + registryServer + "/" + "PruefungsverwaltungServer");
                  //setja her afganginn
                  //skrifa i variablana
                  System.out.println("********************* Pruefungsverwaltung ***********************");
                  System.out.println("******************** Valdimar Jon Audunsson *********************");
                  System.out.println("*********************** Matrnr: 9914436 *************************");
                  String choice1 = null;
                  int choice = 0;
                  char choice2 = 0;
                  char yourchoice;
                  do {
                  yourchoice = 0;
                  System.out.println("Choose 'a' to make new Test ");
                  System.out.println("Choose 'q' to quit ");
                  System.out.println("Choose a character: ");
                  yourchoice = (char);
                  //System.out.println("Choose an operation: ");
            //choice1 = br.readLine();
                  //choice = Integer.parseInt(choice1); //change String to int
                  switch (yourchoice){
                        case 'a': {
                                  System.out.println("Namen der Pruefung: ");
                                  pruefungsName = br.readLine();
                                  pruefungsName = br.readLine();
                                  System.out.println("Beginn der Pruefung: ");
                                  beginn = br.readLine();
                                  System.out.println("Ende der Pruefung: ");
                                  ende = br.readLine();
                                  System.out.println("Ort der Pruefung: ");
                                  ort = br.readLine();
                                  System.out.println("Pruefer: ");
                                   pruefer = br.readLine();

                                       obj.PruefungAnlegen (p);
                                   //obj.PruefungAnlegen (new Pruefung(pruefungsName, beginn, ende, ort, pruefer));
                                   } break;
                        case 'q': {
                                       System.out.println("Thank you for your visit ");
                                   } break;
                        default: {System.out.println("Wrong number!! Choose again "); } break;
                  }while(yourchoice != 'q');
            } catch (Exception e) {
                  System.out.println("PruefungsverwaltungServer exception: " + e.getMessage());
            //Her getur komid lika eitthvad

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Frankly I don't understand ur requirment and I think their is no one who can do, what is ur requirment Exactly?
U r talking about a hashtable and inserting objects into it, What objects to insert based on what condition and ? what do u want to achieve?
va80Author Commented:
Sorry about that. ill try to make it more understandable....
1. Class Pruefung (it means Test) saves information about Tests (where it is, what it is called, when it begins, ends and where it takes place).  

2.Class PruefungsVerwaltungsClient the main program where the user writes the information about the test and and presses enter and then the function PruefungAnlegen (means make new Test) is supposed to make an object of Class "Pruefung" (Test).  now when many tests are being registered many objects of Class "pruefung" are made and I wanted to put these objects into a Hashtable.  Later on I am supposed to make Class "Student" and these are supposed to register for Tests (Class Pruefung) and these objects of Class Students are also to be Saved in Hashtable.  No Database is to be made.  This is a very simple program... I hope this helps something..when not i will try to explane it more...please response
va80Author Commented:
I tried to make the Hashtable inside the Class "Pruefung" but I am not sure where and how i am supposed to implement the hashtable and how to put the objects of Class "pruefung" in there
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

ok the Java Complier requires that any class member field (like test ) used from a static method (main method) to be a static member field so this is normal

In ur case the PruefungsVerwaltungsClient is to be designed as singletone so u can call it from ur main method, so here is the suggested modifications to

1- add a member method like this:

Hashtable tests;

2- Add a member method of itself (Yes do it!!)
protected static PruefungsVerwaltungsClient instance=null;

3- make the constructor private and add ur member methods initializations specially

tests = new Hashtable();
instance = this;

3- make a method like this:

public PruefungsVerwaltungsClient getInstance()
  if(instance == null)
    instance = new PruefungsVerwaltungsClient();
  return instance;

4- u now can add a method to add tests like this

public void addTest(String key, Pruefung value)
  tests.put(key, value);

5- now from ur main method do this:

PruefungsVerwaltungsClient theClass = PruefungsVerwaltungsClient.getInstance();


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sorry getInstance() to be static

public static PruefungsVerwaltungsClient getInstance()
  if(instance == null)
    instance = new PruefungsVerwaltungsClient();
  return instance;
va80Author Commented:
ok another thing.. in main program where I write the info to be saved in Class "pruefung" for example:                               System.out.println("Namen der Pruefung: ");
                               pruefungsName = br.readLine();
 my compiler wants the Variables to be static such as this "pruefungsName".  Doesnt that mean that this variables cant be changed???
va80Author Commented:
sorry just taking nonesense :)
I am trying it out now

I thinked I have helped quite good here, I deserve some points
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.