Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Card Converter: unsupported class file format of version 50.0

I am attempting to generate a CAP file and an export file from the Wallet.java which comes standard in the Java Card SDK under the samples directory. I compile the class, use the converter and encounter the following:

$ javac -g -d classes/ src/com/sun/javacard/samples/wallet/Wallet.java
$ converter -debug -verbose -classdir "$JC_HOME/samples/src" com.sun.javacard.samples.wallet 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x6:0x1 1.0

Java Card 2.2.2 Class File Converter, Version 1.3
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

parsing /home/user/javacard/java_card_kit-2_2_2/samples/src/com/sun/javacard/samples/wallet/Wallet.class
error: com.sun.javacard.samples.wallet.Wallet: unsupported class file format of version 50.0.

conversion completed with 1 errors and 0 warnings.

My Java version and javac versions are the same, Java 1.6:

$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
$ javac -version
javac 1.6.0_45

I am using JC SDK 2.2.2 on Ubuntu 14.04. The version of the converter is 1.3:

$ converter -version
Java Card 2.2.2 Class File Converter, Version 1.3
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

I cannot seem to resolve this "unsupported class file format of version 50.0" error. I am slightly puzzled as to why I am encountering this error given Java 1.6 is version 50.0.

Has anyone else encountered the same issue?

like image 650
cmanning Avatar asked Feb 17 '16 15:02

cmanning


1 Answers

The Java Card 2.2.2 converter supports at most the Java 5 class file format (hence it tells you that Java 6/version 50.0 is not supported). Thus, you need to specify the source compatibility/class file version when compiling the source code using newer JDK versions:

javac -g -source 1.5 -target 1.5 -d classes/ src/com/sun/javacard/samples/wallet/Wallet.java

Similarly, for Java Card 2.2.1, you would use version 1.2:

javac -g -source 1.2 -target 1.2 -d classes/ src/com/sun/javacard/samples/wallet/Wallet.java

And for Java Card 2.1.1 (JC SDK 2.1.2), you would use version 1.1:

javac -g -source 1.1 -target 1.1 -d classes/ src/com/sun/javacard/samples/wallet/Wallet.java

You can check the version of a class file with the Java class file disassembler (thanks to @cmanning for mentioning this):

javap -v -cp classes/ com.sun.javacard.samples.wallet.Wallet |grep 'version'
like image 105
Michael Roland Avatar answered Sep 17 '22 08:09

Michael Roland