I am using example from this wikipedia Article http://en.wikipedia.org/wiki/Tuple_space#JavaSpaces
import java.lang.*;
import java.rmi.RMISecurityManager;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.entry.Entry;
import net.jini.core.lookup.*;
import net.jini.core.lookup.ServiceRegistrar;
import net.jini.core.lookup.ServiceTemplate;
import net.jini.lookup.entry.Name;
import net.jini.space.JavaSpace;
/**
*
* @author admin
*/
public class findSpace {
LotEntry entry = new LotEntry(); // Create the Entry object
JavaSpace space = (JavaSpace)space(); // Create an Object Space
}
Error in Creating an object space line: space()
cannot find Symbol error
JavsSpace Code:
package net.jini.space;
import java.rmi.MarshalledObject;
import java.rmi.RemoteException;
import net.jini.core.entry.Entry;
import net.jini.core.entry.UnusableEntryException;
import net.jini.core.event.EventRegistration;
import net.jini.core.event.RemoteEventListener;
import net.jini.core.lease.Lease;
import net.jini.core.transaction.Transaction;
import net.jini.core.transaction.TransactionException;
public interface JavaSpace {
public static final long NO_WAIT = 0L;
public Lease write(Entry entry, Transaction t, long l) throws TransactionException, RemoteException;
public Entry read(Entry entry, Transaction t, long l) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException;
public Entry readIfExists(Entry entry, Transaction t, long l) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException;
public Entry take(Entry entry, Transaction t, long l) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException;
public Entry takeIfExists(Entry entry, Transaction t, long l) throws UnusableEntryException, TransactionException, InterruptedException, RemoteException;
public EventRegistration notify(Entry entry, Transaction t, RemoteEventListener rl, long l, MarshalledObject mo) throws TransactionException, RemoteException;
public Entry snapshot(Entry entry) throws RemoteException;
}
You can use it like this:
But the service should be running on port 4160. If it's running on some other port, you need to specify that port number.
Also, you can read more about this here