Javacard applet fails to load on the smartcard with javacardx.framework.math.BigNumber - applet

I am trying to load an applet which utilizes the javacardx.framework.math.BigNumber class. When I attempt to load the generated cap file onto the card, I encounter the following result:
Applet loading failed. Are you sure the CAP file (JC version, packages) is compatible with your card?
pro.javacard.gp.GPException: LOAD failed SW: 6985
at pro.javacard.gp.GPException.check(GPException.java:66)
at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:598)
at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:556)
at pro.javacard.gp.GPTool.main(GPTool.java:503)
If I remove the references to the BigNumber API, the applet can be loaded onto the card. The reference is a simple call to the BigNumber constructor. BigNumber counter = new BigNumber((short) 4);
I am using JCDK 2.2.2. My card information is as follows:
***** CARD DATA
GlobalPlatform card
Version: 2.1.1
TAG3: 1.2.840.114283.3
SCP version: SCP_01_05
TAG5: 1.3.656.840.100.2.1.3
TAG6: 1.3.6.1.4.1.42.2.110.1.2
I have java 7 install locally and I build my javacard applet using the following line: javac -g -d classes -source 1.5 -target 1.5 -classpath $JC_HOME/lib/api_16.jar src/applet/*.java. I am using the GlobalPlatformPro to install my cap files.
Has anyone experienced this before?

Related

Tessarect implementation JAVA

I'm trying to implement OCR recognition through Tessarect.
But at the moment I'm stuck with this error.
This is what I've done so far:
Homebrew tessarect
Download the API
Link the Jar with my project (build path > Configure build path > Add external Jar's
But when I compile my code this is the error
Error opening data file D:/Tess4J/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Warning: Invalid resolution 0 dpi. Using 70 instead.
I've downloaded the eng trained data and I've tried different stuff but I can't figure out how to solve this.
I'm running eclipse in macOS Catalina.
Thanks!
My situation
Set your datapath correctly.
Your location D:/Tess4J/tessdata/eng.traineddata is wrong

Toolchain configuration for softfp using yocto

I have built images for IMX6 Sabersd using yocto as shown below.
#curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
#repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-3.10.53-1.1.0_ga
#repo sync
#source setup-environment build
#bitbake core-image-minimal
During build time it is getting the gcc-4.8 source and compiling tool chian for IMX6. The toochain is using hard floating point(checked using "./arm-poky-linux-gnueabi-gcc -v" and output is having "--float-with=hard" ), my requirement is the toolchain has to use softfp.
The reason behind this is I am using 3rd party pre-built libraries, which are not compatible for hardfp. So during compilation time I am getting errors as shown below.
ld: error: *Executable* uses VFP register arguments, *Library* does not
ld: failed to merge target specific data of file *Library*
Can you help on how I can change the configuration in yocto to compile tool chain with softfp.
I couldn't find which version of yocto freescale is using, but I could see gcc-4.8 recipies under "poky/meta/recipes-devtools/gcc/".
Given that I do not know what core processor you are using.
The files that you want to modify should be in poky/meta/conf/machine/include/
you could also add something like this in conf/local.conf to override:
TARGET_CC_ARCH = "-march=armv7 -mfpu=vfp -mfloat-abi=softfp"

Eclipse run error

When i try to run my code on Eclipse this error appears:
Usage: javaw [-options] class [args...]
(to execute a class)
or javaw [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
-hotspot is a synonym for the "server" VM [deprecated]
The default VM is server.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
i try to coment my entired code and this error still appear.
It seems you haven't set your java path correctly.
Setting Up Eclipse with Java 1.6 on Windows
How To Install and Get Started with Java Programming
Run eclipse in clean mode
Edit the eclipse.ini file located in your Eclipse install directory and insert -clean as the first line.
If this is happening to a specific project only and other projects are running fine then your default run configuration might have changed. You may try the following
- Run -> Run As -> 1 Java Application.
I fixed this issue by deleting some of my old runtime configurations. Eclipse then started automatically generating them again.

Running SimpleOpenNI and leJOS in same project

We have a project in which we want to control a Lego Mindstorms robot with the Microsoft Kinect sensor. We decided to use SimpleOpenNI with Processing to read the sensor and leJOS to control the robot for a simple reason: since both is in Java, we can specifiy a kind of RoboHandler and call its methods from the sensor reading class.
In order to achieve that, we downloaded the leJOS plugin for eclipse, created a new leJOS NXT project and put the processing and SimpleOpenNI libraries in the build path. Note that to use SimpleOpenNI, it is required an old processing version without Java.
Now the problem is, that when installing leJOS, it strictly requires a 32-bit Java JDK, so I had to download this and point to it at installation.
At this point, following build paths are in the project:
LeJOS NXT Runtime (which has among others java.awt classes)
core.jar (used to run Processing in eclipse)
SimpleOpenNI.jar
Having all this, and setting up a first Processing sketch like
import processing.core.*;
public class Test extends PApplet{
(....)
}
results in following error code:
Multiple markers at this line
- The type java.awt.event.MouseMotionListener cannot be resolved. It is indirectly referenced from
required .class files
- The type java.applet.Applet cannot be resolved. It is indirectly referenced from required .class files
- The type java.awt.event.MouseListener cannot be resolved. It is indirectly referenced from required .class files
- The hierarchy of the type FirstTry is inconsistent
- The type java.awt.event.FocusListener cannot be resolved. It is indirectly referenced from required .class files
- The type java.awt.event.KeyListener cannot be resolved. It is indirectly referenced from required .class files
When I downloaded the Processing without Java version, I wasn't able to choose from 32bit- or 64bit version. The SimpleOpenNI is installed as 64bit-version.
When adding the 64bit-JDK (eclipse workspace default) as workspace too, the error disappears, but when trying to run a sketch, following error gets printed in the console:
Invalid layout of java.lang.Thread at name
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:128), pid=9176, tid=8740
# fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_04-b22
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.0-b21 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Valentino\Desktop\workspaces\workspace_processing\RoboZeugs\bin\hs_err_pid9176.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
So in my oppinion there is a problem with the JDK versions (32 and 64 bit), but there must be a way to handle this. Has anyone experience on this specific topic, maybe even with Kinect -> Mindstorms? Can anybody tell me what this error exactly means?
You're mixing classes that are designed to run with the JVM on the NXT brick (i.e. everything in classes.jar) with classes that are designed to run with a fully fledged JVM on the PC.
Don't do that. If you want to remote control an NXT, use pccomms.jar and everything else in lib/pc. But never add classes.jar or anything else in lib/nxt to the classpath when you're starting a Java program on your PC.
The error message about java.lang.Thread is probably due to the fact, that java.lang.Thread in classes.jar in by no means compatible with java.lang.Thread that comes with the JVM on your PC.

How to edit build properties of a Java Library

There seem to be some similar questions, but nothing quite specific enough, I hope this is OK.
I am wondering how to edit the build properties of the Jamod MODBUS library so as to use the RxTx API instead of the deprecated javax.comm. The Library page says this is supported:
You will need an implementation of the Java Communications API extension (javax.comm) installed to be able to run serial modbus applications.
Note that there is also support for building with the gnu.io prefix (RXTX), via the boolean build property build.serial.gnu (true will cause the build process to replace the javax.comm prefix with gnu.io in the sources used for builds).
More info here: http://jamod.sourceforge.net/development/project_build.html
I am unsure how to access this file, or the technique for doing so. Do I need to create it or edit and existing one? I have look for build.xml in the project, but no luck, and have googled many times. Any help very much appreciated.
Just open the proyect source (you can download it from rxtx) with an IDE (for example Netbeans) then replace every appearance of javax.comm by gnu.io, from rxtx, add RXTXcomm.jar library to project, and if you are using windows then copy and rxtxSerial.dll for example to C:\windows\system32.
It will work. Good Luck
The " Modbus Jamod Project - Original " folder contains the original project is available at
Web http://jamod.sourceforge.net/ . This project has a significant dependence :
[1 ] javax.comm : comm : jar :3.0 -u1
Description : The Java Communications 3.0 API is a Java extension That Facilitates develop developing platform -independent communications applications for technologies : such as Smart Cards , embedded systems, and point -of -sale devices , financial services devices , fax , modems, display terminals , and robotic equipment .
This API is not available from Oracle repositories .
That's why you have to open the " Jamod -1.2 -SNAPSHOT - sources.jar " project and recompile using other libraries for serial communication. This project is now ready to " Modbus Jamod Project with CXR " to 64 Bits.
METHOD OF SOLUTION OF DEPENDENCE
-------------------------------------------
To recompile the Jamod (Modbus Jamod Project - Original) project, you must open the project with Netbeans clear the javax.comm library , and replaced with the rxtx library. CXR This library can be selected which are in the " CXR - Serial comms Java " folder , ie :
[1 ] MFZ - rxtx -2.2- 20081207 -linux- i386
[2 ] MFZ - rxtx -2.2- 20081207 -x86_64 -linux
[3 ] MFZ - rxtx -2.2- 20081207 -win- ia64
[4 ] MFZ - rxtx -2.2- x64 -win- 20081207
[5 ] MFZ - rxtx -2.2- x86 -win- 20081207
We must take into account the following when choosing :
Windows
-------
Select a binary build - x64 or x86 (based on Which version of
the JVM you are installing to)
NOTE : You MUST match your architecture . You can not install the i386
version on a 64 - bit version of the JDK and vice - versa.
For a JDK installation:
Copy RXTXcomm.jar ---> <JAVA_HOME> \ jre \ lib \ ext
Copy rxtxSerial.dll ---> <JAVA_HOME> \ jre \ bin
Copy rxtxParallel.dll ---> <JAVA_HOME> \ jre \ bin
Linux
-----
Select a binary build - x86_64 or i386 (based on Which version of
the JVM you are installing to)
NOTE : You MUST match your architecture . You can not install the i386
version on a 64 - bit version of the JDK and vice - versa.
For a JDK installation on i386 architecture =
Copy RXTXcomm.jar ---> <JAVA_HOME> / jre / lib / ext
Copy librxtxSerial.so ---> <JAVA_HOME> / jre/lib/i386 /
Copy librxtxParallel.so ---> <JAVA_HOME> / jre/lib/i386 /
NOTE : For a JDK installation on architecture = x86_64 , just change the
i386 to x86_64 above.
-------------------------------------------------- -----------------------------------------------
After this replace the javax.comm library , the Jamod (Modbus Jamod Project - Original) project is recompiled , and the generated Jar Crossover is added.
When the Crossover project contains the library Jamod repaired , it will have to also add the RXTX library to Crossover.
Done.
-------------------------------------------------- -----------------------------------------------
There is a copy of a build.xml file if you download the source ZIP of version 1.2rc1 at http://sourceforge.net/projects/jamod/files/jamod/1.2/jamod-1.2rc1-src.zip/download
If you unzip, you will find build.xml and build-snap.xml, as well as the build.properties file, which lets you specify the build.serial.gnu.
You then just need to install ant and run it in the directory to initiate the build.
Edit: I also didn't have Apache Forrest installed, which appears to be using for generating the docs, so I needed to comment out all references to Forrest in the build.xml as well.