I'm newer in Java Card Platform so please be patient with me. I'm trying to develop an RMI application for the Java Card 3 Platform. My IDE is Eclipse and my OS is Windows 10. I start by creating a simple interface IContor.java
responsible for increasing, decreasing, etc. certain values.
Here is my interface:
package sid;
import java.rmi.Remote;
import java.rmi.RemoteException;
import javacard.framework.UserException;
public interface IContor extends Remote{
public void Incrementer()throws RemoteException,UserException;
public void Decrementer()throws RemoteException,UserException;
public byte GetValue()throws RemoteException,UserException;
public void Init(byte value)throws RemoteException,UserException;
}
Then I provide an implementation for this interface which I named Contor.java
:
package sid;
import java.rmi.RemoteException;
import javacard.framework.UserException;
import javacard.framework.service.CardRemoteObject;
public class Contor extends CardRemoteObject implements IContor {
private byte contor = 0;
@Override
public void Incrementer() throws RemoteException, UserException {
++contor;
}
@Override
public void Decrementer() throws RemoteException, UserException {
--contor;
}
@Override
public byte GetValue() throws RemoteException, UserException {
return contor;
}
@Override
public void Init(byte value) throws RemoteException, UserException {
contor = value;
}
}
My Test applet worked ok. Below I wrote that peace of code:
package sid;
import javacard.framework.*;
import javacard.framework.service.Dispatcher;
import javacard.framework.service.RMIService;
public class Test extends Applet {
Dispatcher dispatcher;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new Test().register();
}
protected Test() {
RMIService rmiService = new RMIService(new Contor());
dispatcher = new Dispatcher((short)1);
dispatcher.addService(rmiService,Dispatcher.PROCESS_COMMAND);
}
@Override
public void process(APDU apdu) {
dispatcher.process(apdu);
}
}
This is a standard piece of code. However I want to create a client which uses that interface which implements the interface Remote
. So I create a Java application in which I copied the IContor.java
interface. Then I opened a command prompt and do the following things:
- Go into the directory where the source files of the first project is located (
cd bla_bla/Contor/src
) - Go a directory up (
cd ..
) - Go into bin directory (
cd bin
)
Here I have located the name of the package ( sid
) and into package sid
I have those three files (Contor.class
, IContor.class
and Test.class
).
Then I typed the following command on the command prompt:
rmic -v1.2 -classpath .;%JC_CLASSIC_HOME%lib/tools.jar -sid/Contor
but I got the following error:
Class javacard.framework.service.CardRemoteObject not found in class sid.Contor.
I replace the tools.jar
with api_classic.jar
but I still get the same error .
The %JC_CLASSIC_HOME%
contains the path to the Java Card 3 development kit. tools.jar
contains compiled implementations of packages javacard.framework
, javacard.security
, javacardx.biometry
, javacardx.external
and javacardx.framework.tlv
. My bout is to generate a client application in bin/sid
directory.My %JC_CLASSIC_HOME%
value is C:\Program Files (x86)\Oracle\Java Card Development Kit 3.0.5ga\
and I'm using JDK 1.8
Here is my Package Explorer from Eclipse :
api_classic.jar
but I followed the documentation from Oracle and writetools.jar
instead but none seems the work. PS : -sid/Contor is bad because rmic will expect '.' symbol and not '/' symbol because of the packages . – Fariss