JavaCard Applet Development Related Questions and Answers.
-
lefibr
- Posts: 18
- Joined: Thu Feb 18, 2016 2:38 am
- Points :171
-
Contact:
Post
by lefibr » Thu Nov 10, 2016 11:43 pm
!!Help!!
When I use javax.smartcardio, I can't access any classes in this package.Why? Is there anyone tell me what happened?
Gracias!
My code:
Code: Select all
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
// get the first terminal
CardTerminal terminal = terminals.get(0);
// establish a connection with the card
Card card = terminal.connect("T=0");
System.out.println("card: " + card);
CardChannel channel = card.getBasicChannel();
ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
System.out.println("response: " + toString(r.getBytes()));
// disconnect
card.disconnect(false);
-
Crawford
- Posts: 39
- Joined: Thu Sep 17, 2015 11:50 pm
- Points :246
-
Contact:
Post
by Crawford » Fri Nov 11, 2016 3:10 am
If you use eclipse, hover the mouse pointer over classes which has problems and then check the prompt.
-
lefibr
- Posts: 18
- Joined: Thu Feb 18, 2016 2:38 am
- Points :171
-
Contact:
Post
by lefibr » Fri Nov 11, 2016 4:49 am
Here is the prompt:
Access restriction: The type 'TerminalFactory' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_101\lib\rt.jar')
And I have resolved this problem just now.
Last edited by
lefibr on Fri Nov 11, 2016 4:55 am, edited 1 time in total.
-
lefibr
- Posts: 18
- Joined: Thu Feb 18, 2016 2:38 am
- Points :171
-
Contact:
Post
by lefibr » Fri Nov 11, 2016 4:54 am
My Solution:
1 Package Explorer;
2 Right click the project -> Build Path -> Configure Build Path ...;
3 Dialog Properties for MyProject -> Java Build Path -> Tab "Libraries";
4 JRE System Library -> Access rules -> Edit;
5 Type Access Rules -> Add...;
6 Resolution: Accessible and Rule Pattern: javax/smartcardio/*;
7 OK -> OK -> OK;
8 I can access all Class in package javax.smartcardio!
-
Crawford
- Posts: 39
- Joined: Thu Sep 17, 2015 11:50 pm
- Points :246
-
Contact:
Post
by Crawford » Fri Nov 11, 2016 5:36 am
Thanks for your back to post the solution. This wiil be a reference for those who will experience the same problem with you.
-
andromeda92
- Posts: 38
- Joined: Tue Aug 18, 2020 6:08 pm
- Points :320
-
Contact:
Post
by andromeda92 » Sun Sep 06, 2020 6:46 pm
For me, the solution don't work all class method from smartcardio can't be resolved.
I use Eclipse 2020-06 64 bit last version windows 10
any idea ?
what is wrong ?
EDIT:
Resolved, it's not javax/smartcardio/*; but javax/smartcardio/**
-
kuafu
- Posts: 317
- Joined: Thu Jun 25, 2015 2:09 am
- Points :4559
-
Contact:
Post
by kuafu » Sun Sep 06, 2020 8:59 pm
Code: Select all
grant codeBase "jrt:/java.smartcardio" {
permission javax.smartcardio.CardPermission "*", "*";
permission java.lang.RuntimePermission "loadLibrary.j2pcsc";
permission java.lang.RuntimePermission
"accessClassInPackage.sun.security.jca";
permission java.lang.RuntimePermission
"accessClassInPackage.sun.security.util";
permission java.util.PropertyPermission
"javax.smartcardio.TerminalFactory.DefaultType", "read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "sun.arch.data.model", "read";
permission java.util.PropertyPermission
"sun.security.smartcardio.library", "read";
permission java.util.PropertyPermission
"sun.security.smartcardio.t0GetResponse", "read";
permission java.util.PropertyPermission
"sun.security.smartcardio.t1GetResponse", "read";
permission java.util.PropertyPermission
"sun.security.smartcardio.t1StripLe", "read";
// needed for looking up native PC/SC library
permission java.io.FilePermission "<<ALL FILES>>","read";
permission java.security.SecurityPermission "putProviderProperty.SunPCSC";
permission java.security.SecurityPermission
"clearProviderProperties.SunPCSC";
permission java.security.SecurityPermission
"removeProviderProperty.SunPCSC";
};
add policy to default.policy in {Your JDK path}\lib\security. MY JDK is JDK14.
JDK8 add policy to {java.home}\lib\security\java.policy (Windows)
well
Users browsing this forum: No registered users and 19 guests
JavaCard OS : Disclaimer
Board Disclaimer
The views and comments posted in these fora are personal and do not necessarily represent the those of the Management of JavaCard OS.
The Management of JavaCard OS does not, under any circumstances whatsoever, accept any responsibility for any advice, or recommentations, made by, or implied by, any member or guest vistor of JavaCard OS that results in any loss whatsoever in any manner to a member of JavaCard OS, or to any other person.
Furthermore, the Management of JavaCard OS is not, and cannot be, responsible for the content of any other Internet site(s) that have been linked to from JavaCard OS.