Convert to .cap error- invalid AID 1.0 in Eclipse - eclipse

This is the source code that I want to upload to my card :
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
public class ReadMemo extends Applet {
private ReadMemo() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new ReadMemo().register();
}
public void process(APDU arg0) throws ISOException {
// TODO Auto-generated method stub
}
}
As you see, the program do nothing! but why when I want to convert it to .cap file, I receive this error :
invalid AID 1.0
Note :
my package ID : 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07
my applet ID : 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x08

Move your code out of the default package (never use the default package in Java). Because the package_name argument is empty, the arguments have been shifted to the left, and it will now see the version number as an AID. Hence the strange error.

Related

How to download and install NFC sample applet on Fudan FM1280 dual interface card?

I have a dual interface Fudan FM1280 which supports both contact (ISO7816) and contactless (ISO14443) interfaces connected to the same chip card. All I want to do is to install an HCI applet on this card.
To do so, I have used the example code from Simalliance (Mobile Near Field Communication (Mobile NFC) Stepping Stones) named "a Reader Mode Applet based on ToolKit interaction". The source code for that example is as below:
package pkgReaderModeApplet;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacard.framework.MultiSelectable;
import uicc.toolkit.ToolkitConstants;
import uicc.toolkit.ToolkitException;
import uicc.toolkit.ToolkitInterface;
import uicc.toolkit.ToolkitRegistry;
import uicc.hci.framework.HCIDevice;
import uicc.hci.framework.HCIMessage;
import uicc.hci.framework.HCIService;
import uicc.hci.services.connectivity.ConnectivityService;
import uicc.hci.services.readermode.ReaderListener;
import uicc.hci.services.readermode.ReaderMessage;
import uicc.hci.services.readermode.ReaderService;
public class ReaderModeApplet extends Applet implements ReaderListener, MultiSelectable, ToolkitConstants, ToolkitInterface {
private ToolkitRegistry myToolKitReg;
private HCIService myReaderService;
private ConnectivityService myConnectivityService;
private ReaderModeApplet() {
myReaderService = (ReaderService) HCIDevice.getHCIService(HCIDevice.READER_SERVICE_ID);
myReaderService.register(this);
}
public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
new ReaderModeApplet().register();
}
public void processToolkit(short event) throws ToolkitException {
switch(event) {
case EVENT_MENU_SELECTION:
myReaderService.activateEvent(ReaderListener.EVENT_TARGET_DISCOVERED);
break;
case EVENT_EVENT_DOWNLOAD_HCI_CONNECTIVITY:
myToolKitReg.clearEvent(EVENT_EVENT_DOWNLOAD_HCI_CONNECTIVITY);
break;
}
}
public void process(APDU arg0) throws ISOException {
// TODO Auto-generated method stub
}
public void onCallback(byte event, HCIMessage myHCIMessage) {
// First: Reception of Datas
short offset = myHCIMessage.getReceiveOffset();
short length = myHCIMessage.getReceiveLength();
byte[] IncomingBuffer = myHCIMessage.getReceiveBuffer();
switch(event){
//Target Discovered !!!
case ReaderListener.EVENT_TARGET_DISCOVERED:
//Activation of relevant events
myReaderService.activateEvent(ReaderListener.EVENT_WRITE_EXCHANGE_DATA_RESPONSE);
myReaderService.activateEvent(ReaderListener.EVENT_GET_PARAMETER_RESPONSE);
// Check if status is OK
if (IncomingBuffer[(short)(offset) ] == ReaderMessage.SINGLE_TARGET_STATUS) {
// Copy your Datas into IncomingBuffer
// and send the first message
// prepareAndSendWriteXchgDataCommand(byte timeout, byte[] data, short offset, short len)
((ReaderMessage)myHCIMessage).prepareAndSendWriteXchgDataCommand((byte) -1, IncomingBuffer, (short)offset, (short)length);
// Or retrieves informations on the Target discovered
((ReaderService)myReaderService).getReaderRFType();
((ReaderMessage)myHCIMessage).prepareAndSendGetParameterCommand(ReaderMessage.
PARAM_ID_TYPE_B_READER_AFI);
} else {
// If status is equal to MULTIPLE_TARGET_STATUS
((ReaderMessage)myHCIMessage).restartReaderModeProcedure();
// Warn the user
}
break;
//Response received !!
case ReaderListener.EVENT_WRITE_EXCHANGE_DATA_RESPONSE:
//First check if response is a Success
if(myHCIMessage.getInstruction() == (byte)(HCIMessage.RESP_ANY_OK)) {
//Copy your Datas into IncomingBuffer
// and send your next message
((ReaderMessage)myHCIMessage).prepareAndSendWriteXchgDataCommand((byte) -1, IncomingBuffer, (short)offset, (short)length);
// Or you have all the datas and you want to process them
myToolKitReg.setEvent(ToolkitConstants.EVENT_EVENT_DOWNLOAD_HCI_CONNECTIVITY);
myConnectivityService = (ConnectivityService)HCIDevice.getHCIService(HCIDevice.CONNECTIVITY_SERVICE_ID);
myConnectivityService.prepareAndSendConnectivityEvent();
myReaderService.deactivateEvent(ReaderListener.EVENT_TARGET_DISCOVERED);
} else {
//Or restart the procedure
((ReaderMessage)myHCIMessage).restartReaderModeProcedure();
}
break;
case ReaderListener.EVENT_GET_PARAMETER_RESPONSE:
default:
break;
}
}
public void deselect(boolean arg0) {
// TODO Auto-generated method stub
}
public boolean select(boolean arg0) {
// TODO Auto-generated method stub
return true;
}
}
I am using Java card 2.2.2, hci-api-for-java-card-REL-920 and uicc-api-for-java-card-REL-13_0 to compile this code (using Eclipse) and it results in the cap file needed to be downloaded on card.
I am using pyApduTool to interface card. As I connect to card and try to download this applet on my card, I get an error as below and never get to installing step for the downloaded file.
This card originally contains few packages as:
And no applet installed. Now, what is the problem with applet downloading on card?

Error in Eclipse when compiling code but not when is validated

I have Eclipse Java EE IDE Helios Service Release 2 Build id: 20110218-0911; I am trying use them with SeleniumRC and when I compile the code appears the next error message:
Type mismatch: cannot convert from DataProviderSites to annotation
The attribute DataProviderSites is undefined for the annotation type Test
However, when I validate the code, is visualized "the validation completed with no errors or warnings"
The Code in DataProviderSites.java is:
package script;
import org.junit.Test;
import junit.framework.TestCase;
import com.thoughtworks.selenium.SeleneseTestBase;
import org.junit.AfterClass;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.*;
import java.io.File;
import jxl.*;
public class DataProviderSites extends SeleneseTestBase {
#BeforeClass
public void setUp() throws Exception {
SeleniumServer seleniumserver=new SeleniumServer();
seleniumserver.boot();
seleniumserver.start();
setUp("http://www.examinator.ws/", "*firefox");
selenium.open("/");
selenium.windowMaximize();
selenium.windowFocus();
}
#DataProviderSites
(name = "DPS1")
public Object[][] createData1() throws Exception{
Object[][] retObjArr=getTableArray("test\\Resources\\Data\\sitios.xls",
"DataPool", "TestData");
return(retObjArr);
}
#Test(DataProviderSites = "DPS1")
public void testDataProviderSites(String nombre) throws Exception {
selenium.type("sitio", nombre);
if (selenium.isTextPresent("examinator"))
selenium.click("xpath=/descendant::button[#type='submit']");
else
selenium.waitForPageToLoad("30000");
selenium.click("xpath=/descendant::a[text()='"+nombre+"']");
}
#AfterClass
public void tearDown(){
selenium.close();
selenium.stop();
}
public String[][] getTableArray(String xlFilePath, String sheetName, String tableName) throws Exception{
String[][] tabArray=null;
Workbook workbook = Workbook.getWorkbook(new File(xlFilePath));
Sheet sheet = workbook.getSheet(sheetName);
int startRow,startCol, endRow, endCol,ci,cj;
Cell tableStart=sheet.findCell(tableName);
startRow=tableStart.getRow();
startCol=tableStart.getColumn();
Cell tableEnd= sheet.findCell(tableName, startCol+1,startRow+1, 100, 64000, false);
endRow=tableEnd.getRow();
endCol=tableEnd.getColumn();
System.out.println("startRow="+startRow+", endRow="+endRow+", " +
"startCol="+startCol+", endCol="+endCol);
tabArray=new String[endRow-startRow-1][endCol-startCol-1];
ci=0;
for (int i=startRow+1;i<endRow;i++,ci++){
cj=0;
for (int j=startCol+1;j<endCol;j++,cj++){
tabArray[ci][cj]=sheet.getCell(j,i).getContents();
}
}
return(tabArray);
}
}
Anybody have a idea to resolve this?
Just click the error and click "Convert to TestNG(Annotations)".
Validation does not check the logic like it does not check for syntax of code.
But when we compile the program it will check for syntax so you got type cast exception.
Validation success does not mean program is correct.
I think annotations(#Test(DataProviderSites = "DPS1"), #DataProviderSites
(name = "DPS1")) causes the exception.

Reading xls file in gwt

I am looking to read xls file using the gwt RPC and when I am using the code which excecuted fine in normal file it is unable to load the file and giving me null pointer exception.
Following is the code
{
{
import com.arosys.readExcel.ReadXLSX;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.Preview.client.GWTReadXL;
import java.io.InputStream;
import com.arosys.customexception.FileNotFoundException;
import com.arosys.logger.LoggerFactory;
import java.util.Iterator;
import org.apache.log4j.Logger;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
*
* #author Amandeep
*/
public class GWTReadXLImpl extends RemoteServiceServlet implements GWTReadXL
{
private String fileName;
private String[] Header=null;
private String[] RowData=null;
private int sheetindex;
private String sheetname;
private XSSFWorkbook workbook;
private XSSFSheet sheet;
private static Logger logger=null;
public void loadXlsxFile() throws Exception
{
logger.info("inside loadxlsxfile:::"+fileName);
InputStream resourceAsStream =ClassLoader.getSystemClassLoader().getSystemResourceAsStream("c:\\test2.xlsx");
logger.info("resourceAsStream-"+resourceAsStream);
if(resourceAsStream==null)
throw new FileNotFoundException("unable to locate give file");
else
{
try
{
workbook = new XSSFWorkbook(resourceAsStream);
sheet = workbook.getSheetAt(sheetindex);
}
catch (Exception ex)
{
logger.error(ex.getMessage());
}
}
}// end loadxlsxFile
public String getNumberOfColumns() throws Exception
{
int NO_OF_Column=0; XSSFCell cell = null;
loadXlsxFile();
Iterator rowIter = sheet.rowIterator();
XSSFRow firstRow = (XSSFRow) rowIter.next();
Iterator cellIter = firstRow.cellIterator();
while(cellIter.hasNext())
{
cell = (XSSFCell) cellIter.next();
NO_OF_Column++;
}
return NO_OF_Column+"";
}
}
}
I am calling it in client program by this code:
final AsyncCallback<String> callback1 = new AsyncCallback<String>() {
public void onSuccess(String result) {
RootPanel.get().add(new Label("In success"));
if(result==null)
{
RootPanel.get().add(new Label("result is null"));
}
RootPanel.get().add(new Label("result is"+result));
}
public void onFailure(Throwable caught) {
RootPanel.get().add(new Label("In Failure"+caught));
}
};
try{
getService().getNumberOfColumns(callback1);
}catch(Exception e){}
}
Pls tell me how can I resolve this issue as the code runs fine when run through the normal java file.
Why are using using the system classloader, rather than the normal one?
But, If you still want to use then look at this..
As you are using like a web application. In that case, you need to use the ClassLoader which is obtained as follows:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
This one has access to the all classpath paths tied to the webapplication in question and you're not anymore dependent on which parent classloader (a webapp has more than one!) has loaded your class.
Then, on this classloader, you need to just call getResourceAsStream() to get a classpath resource as stream, not the getSystemResourceAsStream() which is dependent on how the webapplication is started. You don't want to be dependent on that as well since you have no control over it at external hosting:
InputStream input = classLoader.getResourceAsStream("filename.extension");
The location of file should in your CLASSPATH.

Problem on aboutBox() in java

I'm developing a javadesktop application in Netbeans 6.9 and everything is perfect but...it gives me an error on this :
#Action
public void showAboutBox()
{
if (aboutBox == null) {
JFrame mainFrame = Mp4App.getApplication().getMainFrame();
aboutBox = new mp4AboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
and this is the error :
Compiling 1 source file to Q:\Mp3 App\mp4-beta\mp4\build\classes
Q:\Mp3 App\mp4-beta\mp4\src\mp4\Mp4View.java:223: cannot find symbol
symbol : class mp4AboutBox
location: class mp4.Mp4View
aboutBox = new mp4AboutBox(mainFrame);
1 error
Q:\Mp3 App\mp4-beta\mp4\nbproject\build-impl.xml:603:
The following error occurred while executing this line:
Q:\Mp3 App\mp4-beta\mp4\nbproject\build-impl.xml:284: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 8 seconds)
the real problem is that this is the code generated from netbeans...also if you create a new Project->java->Destop Application and you leave it there without adding nothing,it gives always me the same problem... what to do ????????????
netbeans version: 6.9.1
jdk version: 7
O.S : Windows 7 32 bit
You shouldn't create your GUI using Netbeans because it generates unreadable code. The Swing-Package is pretty straight forward, so you should use it.
To the Error: Do you have a mp4AboutBox-class and what is in it?
You might be missing an import. Provide your imports in that file.
I had a similar question that I got the solution to by re-installing netbeans 6.9.1.
This is the solution I came up with from that:
TestProject class:
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
public class TestProject extends SingleFrameApplication {
#Override protected void startup() {
show(new AppView(this));
}
#Override protected void configureWindow(java.awt.Window root) { }
public static TestProject getApplication() {
return Application.getInstance(TestProject.class);
}
public static void main(String[] args) {
launch(TestProject.class, args);
}
}
AppView JFrame:
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;
public class AppView extends FrameView {
public AppView(SingleFrameApplication app) {
super(app);
JFrame mainFrame = TestProject.getApplication().getMainFrame();
AboutBox newAboutBox = new AboutBox();
newAboutBox.setLocationRelativeTo(mainFrame);
TestProject.getApplication().show(newAboutBox);
}
}

GWT implementation

i have following code
package org.david.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.logical.shared.BeforeSelectionEvent;
import com.google.gwt.event.logical.shared.BeforeSelectionHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.TabBar;
public class TabBar1 implements EntryPoint{
#Override
public void onModuleLoad(){
TabBar bar=new TabBar();
bar.addTab("foo");
bar.addTab("bar");
bar.addTab("baz");
bar.addSelectionHandler(new SelectionHandler(){
public void onSelection(SelectionEvent event){
//let user know what you just did
Window.alert("you clicked tab"+event.getSelectedItem());
}
});
// Just for fun, let's disallow selection of 'bar'.
bar.addBeforeSelectionHandler(new BeforeSelectionHandler() {
public void onBeforeSelection(BeforeSelectionEvent event) {
if (event.getItem().intValue() == 1) {
event.cancel();
}
}
});
}
}
but i have following errors
ompiling 1 source file to C:\XAMPP\xampp\htdocs\TabBar1\build\web\WEB-INF\classes
C:\XAMPP\xampp\htdocs\TabBar1\src\java\org\david\client\TabBar1.java:28: cannot find symbol
symbol : method intValue()
location: class java.lang.Object
if (event.getItem().intValue() == 1) {
Note: C:\XAMPP\xampp\htdocs\TabBar1\src\java\org\david\client\TabBar1.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
C:\XAMPP\xampp\htdocs\TabBar1\nbproject\build-impl.xml:518: The following error occurred while executing this line:
C:\XAMPP\xampp\htdocs\TabBar1\nbproject\build-impl.xml:248: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
please help
BeforeSelectionEvent should be BeforeSelectionEvent<Integer> so that getItem() returns an Integer instead of an Object.
Object doesn't have an intValue() method, and Integer does.
You should have also seen an unchecked conversion warning in your compile saying something to that effect.