How to add JavaCard packages to JavaCard applet? - netbeans-8

I am trying to build a simple Hello world JavaCard applet.I am using NetBeans IDE.
I am following this tutorial.
Here is my code:
package classicapplet1;
import javacard.framework.*;
import java.rmi.Remote;
import javacard.framework.service.Dispatcher;
import javacard.framework.service.RMIService;
import javacard.framework.service.Service;
public class JavaCardApplet extends Applet {
HelloWorld hello;
Dispatcher disp;
Service svc;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new JavaCardApplet();
}
private JavaCardApplet() {
// register();
hello = new HelloWorld();
svc=new RMIService((Remote) hello);
disp = new Dispatcher((short)1);
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
}
public static void install(byte[] buf, short ofs, short len){
(new JavaCardApplet()).register();
}
public void process(APDU apdu) {
//Insert your code here
disp.process(apdu);
}
}
The IDE doesnt show any error or warning on the editor, but WHen I try to build the code: The foloowing things display in the debug console:
ant -f "C:\\Users\\Tera\\Documents\\NetBeansProjects\\JavaCardApplet" run
__reset_for_debug__:
init-platform-properties:
Using JavaCard Platform Definition at C:\Users\Tera\AppData\Roaming\NetBeans\8.1\config\Services\Platforms\org-netbeans-api-java-Platform\javacard_default.jcplatform
Java Card Home is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition (Java Card Platform)
init-ri-properties:
init-device-properties:
Platform device property name is jcplatform.javacard_default.devicespath
Computed device folder path is C:\Users\Tera\AppData\Roaming\NetBeans\8.1\config\org-netbeans-modules-javacard\servers\javacard_default
Platform device file path property name is C:\Users\Tera\AppData\Roaming\NetBeans\8.1\config\org-netbeans-modules-javacard\servers\javacard_default\Default Device.jcard
Deploying to device Default Device http port 8019
init-keystore:
Keystore is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition/samples/keystore/a.keystore
build-dependencies:
unpack-dependencies:
compile:
Compiling 2 source files to
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\build\APPLET-INF\classes
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:11: error: package javacard.framework.service does not exist
import javacard.framework.service.Dispatcher;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:12: error: package javacard.framework.service does not exist
import javacard.framework.service.RMIService;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:13: error: package javacard.framework.service does not exist
import javacard.framework.service.Service;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:22: error: cannot find symbol
Dispatcher disp;
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:23: error: cannot find symbol
Service svc;
symbol: class Service
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:48: error: cannot find symbol
svc=new RMIService((Remote) hello);
symbol: class RMIService
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:49: error: cannot find symbol
disp = new Dispatcher((short)1);
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:50: error: cannot find symbol
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
symbol: variable Dispatcher
location: class JavaCardApplet
8 errors
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\nbproject\build-impl.xml:301: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
Note:NetBEans IDE has the JavaCard Plugin Installed.

Add the api_classic.jar library and its export path to the libraries of your project manually. This file is exist under this path:
<NetbeansInstalledDirectory>\javacard\JCDK3.0.2_ConnectedEdition\lib
Step by step for beginners:
And now, try to build it again.

Related

Migrating ADAL Filter to MSAL on Linux running Java 11 (maven) - AuthenticationResponseParser.parse() throws exception

in AuthenticationResponseParser.parse(new URI(fullUrl), params);
where params is
Map<String, List<String>>
and is created as
for (String key : httpRequest.getParameterMap().keySet()) {
params.put(key, Collections.singletonList(httpRequest.getParameterMap().get(key)[0]));
}
throws exception
Error: class java.util.Collections$SingletonList cannot be cast to class java.lang.String (java.util.Collections$SingletonList and java.lang.String are in module java.base of loader 'bootstrap')
What could be going wrong?
I am using MSALJ maven dependency com.microsoft.azure, msal4j, 1.13.2
Tried to pass String as params but it is expecting List of strings

Android studio JavaDoc error throws a NullPointerException

Android studio cannot create JavaDoc. It throws a null pointer exception and cannot identify any of the android packed items.
...
/home/<user>/AndroidStudioProjects/<project>/app/src/main/java/com/example/simpleparadox/listycity/MainActivity.java:14: error: cannot access ViewGroup
public class MainActivity extends AppCompatActivity {
^
class file for android.view.ViewGroup not found
javadoc: error - fatal error encountered: java.lang.NullPointerException
javadoc: error - Please file a bug against the javadoc tool via the Java bug reporting page
(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
for duplicates. Include error messages and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.runPhase(TypeEnter.java:934)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:282)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.doCompleteEnvs(TypeEnter.java:877)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:251)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:198)
at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:583)
at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:560)
at jdk.javadoc/jdk.javadoc.internal.tool.JavadocEnter.main(JavadocEnter.java:79)
at jdk.javadoc/jdk.javadoc.internal.tool.JavadocTool.getEnvironment(JavadocTool.java:206)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:576)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:432)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:345)
at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
7 errors
Then I found a work around which add -bootclasspath path_to_sdk_android_jar_file in the other command-line argument text box in the JavaDoc dialog.
However, newer Java deprecated -bootclasspath. It throws another error as follows:
error: option --boot-class-path not allowed with target 11
So I used -sourcepath instead. That brought the old error (NullPointerException).
I am pretty much lost at this point.
By the way, if I choose a class with only Java elements (no-android) and create JavaDoc to that specific file only, it creates JavaDoc nicely. But this is not a good workaround for a project with a lot of classes.
I've faced the same issue as yours with several imports errors..
The following solution worked for me ( I got it from mike192's answer, see the link here )
task javadoc(type: Javadoc) {
doFirst {
configurations.implementation
.filter { it.name.endsWith('.aar') }
.each { aar ->
copy {
from zipTree(aar)
include "**/classes.jar"
into "$buildDir/tmp/aarsToJars/${aar.name.replace('.aar', '')}/"
}
}
}
configurations.implementation.setCanBeResolved(true)
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.implementation
classpath += fileTree(dir: "$buildDir/tmp/aarsToJars/")
destinationDir = file("${project.buildDir}/outputs/javadoc/")
failOnError false
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
All you need to do is to add the code to your build.gradle file right before your dependencies {}
Then, double click on your Ctrl button and execute the following command :
gradle javadoc
The result of the javadoc can be then found in your project's directory \app\build\outputs\javadoc
I hope this works for you

Specified library jar EJBRemoteInterface.jar does not exist

I created class library project named EJBRemoteInterface. Then I created Enterprise applications named it EntAppEJB .I added the Remote reference EJBRemoteInterface applications with EJB Applications . Inside the applications I added session bena which invoke getString () methods . Then I created enterprise client applications to access the getSting methods . I deployed the EJB Applications Into glassfish server . But when i run the client application or tired deployed I am getting following error in server log .#
Exception while deploying the app [EntAppClient] : Specified library jar EJBRemoteInterface.jar does not exist: C:\Users\Khundokar%20Nirjor\Documents\New%20Folder%20(5)\EJBRemoteInterface\dist\EJBRemoteInterface.jar]
Here is the interface .
#Remote
public interface MySessionRemote {
String getResult();
}
Here is the Bean class.
#Stateless
public class MySession implements MySessionRemote {
public String getResult() {
return "This is My Session Bean";
}
}
Here is the client code .
import ejb.MySessionRemote;
import javax.ejb.EJB;
public class Main {
#EJB
private static MySessionRemote mySession;
public static void main(String[] args) {
System.err.println("result = " + mySession.getResult());
}
}
Here is the code when i tried to deploy the applications or run it ..
ant -f "C:\\Users\\Khundokar Nirjor\\Documents\\New Folder (5)\\EntAppClient" -Dnb.internal.action.name=run -DforceRedeploy=false run
init:
EJBRemoteInterface.init:
Deleting: C:\Users\Khundokar Nirjor\Documents\New Folder (5)\EJBRemoteInterface\build\built-jar.properties
EJBRemoteInterface.deps-jar:
Updating property file: C:\Users\Khundokar Nirjor\Documents\New Folder (5)\EJBRemoteInterface\build\built-jar.properties
EJBRemoteInterface.compile:
EJBRemoteInterface.jar:
deps-jar:
compile:
library-inclusion-in-archive:
Building jar: C:\Users\Khundokar Nirjor\Documents\New Folder (5)\EntAppClient\dist\EntAppClient.jar
dist:
pre-run-deploy:
Distributing C:\Users\Khundokar Nirjor\Documents\New Folder (5)\EntAppClient\dist\EntAppClient.jar
GlassFish Server, deploy, null, false
C:\Users\Khundokar Nirjor\Documents\New Folder (5)\EntAppClient\nbproject\build-impl.xml:988: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 0 seconds)
Here is the screen shot the ejb deployment
.
Here is the screen shot of the project .
Here is the screen shot the error .

How to btrace JBoss AS 7

I'm trying to instrument JBoss AS 7 using btrace but can't get it to work. I'm using visualvm 1.3.7 and the btrace workbench 0.6.7 (right click -> "Trace applicaiton..."). I'm always setting the following non-descriptive error.
!!! Error occured
!!! Error occured
What I tried is setting the following VM options
-Djboss.modules.system.pkgs=com.sun.btrace,com.sun.btrace.annotations
-Xbootclasspath/a:/path/to/btrace-boot-1.2.3.jar
but no avail. I am running on Java 8.
Even simple scripts like this don't work:
import static com.sun.btrace.BTraceUtils.println;
import com.sun.btrace.annotations.BTrace;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnMethod;
#BTrace
public class Simple {
#OnMethod(
clazz = "com.acme.Main",
method = "main",
location = #Location(Kind.ENTRY)
)
public static void mainEjbCall() {
println("enter");
}
}
* Update *
Yes, I assume it's a JBoss AS classloader issue but I don't know how to fix it.
I can profile normal Java 8 applications (even though I get an exception from the ASM ClassReader).

Play Framework [2.2.0-Java] Custom 404 page

Hi Everyone I'm using play 2.2.0 built with scala 2.10.2 (running java 1.7.0_45)
I'm trying to make a custom Not Found Page but I don't have any success.
This is the code:
#Override
public Promise<SimpleResult> onHandlerNotFound(RequestHeader request) {
return Promise.<SimpleResult>pure(notFound(
views.html.myerrors.page404.render()
));
}
But I get this error
[error] path\app\Global.java:80: error: cannot find symbol
[error] return Promise.<SimpleResult>pure(notFound(
[error] ^
[error] symbol: method notFound(Html)
[error] location: class Global
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
Does somebody know the reason why and the solution?
Thank you in advance.
notFound is a static method of the play.mvc.Results class.
It is probably not imported in your code. You can try to import it at the beginning of your file :
import static play.mvc.Results.notFound;
...
or import just the Results class if you don't want a static import :
import play.mvc.Results;
...
return Promise.<SimpleResult>pure(Results.notFound(
views.html.myerrors.page404.render()));
...