How to create a java card library (jar file to be used in other programs)

Hi all,
I am working on JCOP and writing quite a bit of applets for the java card . Now i have lots of code that could be reusable for example sending SMS, encryption routine, etc.. So this part of the code i want to put into a utility class and create a package out of it. This utility package i must be able to import into my programs what i write.
I tried the normal way of creating the jar by renaming the CAP file of the utility class, also tried including the /javacard/* files also into the jar file as indicated by sfarmer(active forum member here). But none seems to work. I tried contacting NXP folks and they indicated that it may be possible only by way of Sharable Objects.
But some how i am not convinced why i should use Sharable object for this. So if any one can throw some light into this regard it will be immensely helpful to me and my project.
Regards
Prakash

Hi,
Well the variable defined are as below
public static byte[] msgdata = new byte[255];
private static final byte[] HEADER_TEMPLATE = {
          (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, // Command details tag
               (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x02, // Device Identities tag
               (byte) 0x8D, // Text String tag
               (byte) 0x00, // length
               (byte) 0x04, // Text String tag
the msgdata is declared public so that i can access this as a Class member in my other program doing Utilities.msgdata. But the problem is now that if i dont declare it as final then the compiler gives me the below error
"library has initialized array for non-final, non-static field Utilities, msgdata, [B, attr jc-field: tok 0, public static"
If i make it final then i cannot change it... So now i am stuck..
Any help will be highly appreciated...
Regards
Prakash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to create package and import from jar file?

    Hi all,
    I am writing a software and I am not sure how to create a package for the classes.
    Say I have two classes in the same directory as follows:
    testA.java
    ==========
    package AB;
    public class testA
    public static void main(String[] args){
         testB myB = new testB();
         System.out.println("A test");
    testB.java
    ===========
    package AB;
    public class testB
    public testB(){
         System.out.println("B constructor");
    both file compile without the package heading;
    both file compile using: javac -classpath .\ *.java
    Question 1:
    I cannot run testA by: java -classpath .\ testA
    I think it is a syntax error. What is the correct one?
    If I run testA by: java testA
    The only output I get is: A test
    But I am expecting: B constructor /n A test
    What went wrong?
    Question 2:
    I need to use APIs of another software. I have downloaded a .jar file (xxx.jar) with all the classes in it. And I have put "import xxx.*;" in my source file. But the compiler complains about the importing. What is the right way to copmile it?
    I have read a couple of tutorials but they don't answer my question.
    (I am using windows2000 and don't have the classpath variable.)
    Hope some one can help.
    Thanks a lot

    Try moving testA out of the package and importing 'AB.*;'
    If you have:
    ./testA.class
    ./AB/testb.class
    Then to execute testA from ./ type: java -cp . testA

  • How do you convert a swf or mp4 file into flv using creative cloud programs?

    I am trying to embed a video as HTML5 with Flash fallback into my Dreamwaver site and only have the swf file of the video. 
    Please let me know if you have any ideas about how to convert a swf or mp4 file into flv, without loosing pixels and quality of the swf file.
    Thank you!

    If you have MP4 video, you can use Pickle Player which has built-in Flash fallback for Mozilla.  No conversions required .
    http://www.pickleplayer.com/
    Nancy O.

  • How to create and use library JAR files with command-line tools?

    Development Tools -> General Questions:
    I am trying to figure out how to put utility classes into JAR files and then compile and run applications against those JAR files using the command-line javac, jar, and java tools. I am using jdk1.7.0_17 on Debian GNU/Linux 6.0.7.
    I have posted a simple example with one utility class, one console application class, and a Makefile:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130520-2134.tar.gz
    Here is a console session:
    2013-05-20 21:39:01 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-20 21:39:12 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/hello/HelloConsole.java
    package com.example.hello;
    import static com.example.util.Hello.hello;
    public class HelloConsole {
        public static void main(String [] args) {
         hello("world!");
    2013-05-20 21:39:21 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -f hello
    find . -name '*.class' -delete
    javac src/com/example/util/Hello.java
    javac -cp src src/com/example/hello/HelloConsole.java
    echo "java -cp src com.example.hello.HelloConsole" > hello
    chmod +x hello
    2013-05-20 21:39:28 dpchrist@desktop ~/sandbox/java/jar
    $ ./hello
    hello, world!I believe I am looking for:
    1. Command-line invocation of "jar" to put the utility class bytecode file (Hello.class) into a JAR?
    2. Command-line invocation of "javac" to compile the application (HelloConsole.java) against the JAR file?
    3. Command-line invocation of "java" to run the application (HelloConsole.class) against the JAR file?
    I already know how t compile the utility class file.
    Any suggestions?
    TIA,
    David

    I finally figured it out:
    1. All name spaces must match -- identifiers, packages, file system, JAR contents, etc..
    2. Tools must be invoked from specific working directories with specific option arguments, all according to the project name space.
    My key discovery was that if the code says
    import com.example.util.Hello;then the JAR must contain
    com/example/util/Hello.classand I must invoke the compiler and interpreter with an -classpath argument that is the full path to the JAR file
    -classpath ext/com/example/util.jarThe code is here:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130525-1301.tar.gz
    Here is a console session that demonstrates building and running the code two ways:
    1. Compiling the utility class into bytecode, compiling the application class against the utility bytecode, and running the application bytecode against the utility bytecode.
    2. Putting the (previously compiled) utility bytecode into a JAR and running the application bytecode against the JAR. (Note that recompiling the application against the JAR was unnecessary.)
    (If you don't know Make, understand that the working directory is reset to the initial working directory prior to each and every command issued by Make):
    2013-05-25 14:02:47 dpchrist@desktop ~/sandbox/java/jar
    $ cat apps/com/example/hello/Console.java
    package com.example.hello;
    import com.example.util.Hello;
    public class Console {
        public static void main(String [] args) {
         Hello.hello("world!");
    2013-05-25 14:02:55 dpchrist@desktop ~/sandbox/java/jar
    $ cat libs/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-25 14:03:03 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -rf bin ext obj
    mkdir obj
    cd libs; javac -d ../obj com/example/util/Hello.java
    mkdir bin
    cd apps; javac -d ../bin -cp ../obj com/example/hello/Console.java
    cd bin; java -cp .:../obj com.example.hello.Console
    hello, world!
    mkdir -p ext/com/example
    cd obj; jar cvf ../ext/com/example/util.jar com/example/util/Hello.class
    added manifest
    adding: com/example/util/Hello.class(in = 566) (out= 357)(deflated 36%)
    cd bin; java -cp .:../ext/com/example/util.jar com.example.hello.Console
    hello, world!
    2013-05-25 14:03:11 dpchrist@desktop ~/sandbox/java/jar
    $ tree -I CVS .
    |-- Makefile
    |-- apps
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.java
    |-- bin
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.class
    |-- ext
    |   `-- com
    |       `-- example
    |           `-- util.jar
    |-- libs
    |   `-- com
    |       `-- example
    |           `-- util
    |               `-- Hello.java
    `-- obj
        `-- com
            `-- example
                `-- util
                    `-- Hello.class
    19 directories, 6 filesHTH,
    David

  • How to load a java card applet into a java card

    Dear All,
    I am a novice to java card technology..
    I have done some search on how to load a java card applet into a smart card but haven't found a satisfactory answer. I have read about installer.jar and scriptgen tool but I want to load the applet from a java program and not from command line. It would be of great help if somebody can help me out.
    If somebody can share a sample program which load a javacard applet(.CAP file) into a smart card, I will be very thankful.
    I am able to find some client applications which help us send APDU commands and recieve response APDU's to interact with an applet loaded on to the smart card but not application which actually load the applet.
    I have heard of OCF and GP.. some say that OCF technology is outdated and no longer in use.. can somebosy throw some light on this too..
    cheers,
    ganesh

    hi siavash,
    thanks for the quick response.. i checked out GPShell as suggested, it looked like a tool by which one can load an applet on to card and send some sample apdu commands... but I want to load the applet from the code.
    My application should look something like this.. it will be a swing applicaton where I have a drop down with a list of readers, I select the one desired and then click on "LOAD" after inserting a blank java card, at this point my applet which is stored in my DB should get loaded on to the java card. The next step should be to personalize it where I enter the values for the static variables of my applet and click "PERSONALIZE", at this point all these values should be embedded into APDU commands and sent to the java card for processing.
    For achieving this I am yet to find a comprehensive sample or documentation on the net.
    Please help...
    regards,
    ganesh

  • How to create a job card and how to add waranty card in sales order

    I have one scenario for CS.the scenario is realted to automotive industry. Basically its a trading industry of HCV,MCV,LCV apart from that they will do servicing also. First the customer comes for a service.he is having free services. he will have waranty for spare parts of the vehicle. once he comes for servicing first the executive will take complains from the customer after that a Job card will be issued to the customer. there his chasis no ,engine no and registration no will be there. once enter the chasis no entire customer details has to come. how many free services he is having for how many kilo meters.then job card will go to the spare parts dept.that dept will issue the spare parts.then they will invoice the customer. he will pay the payment.and finally the gate pass will be given to the customer to deliver the vehicle.
    painful area is how to create a job card and how to add waranty in sales order.
    Regards,
    Venkat

    Hi,
    Have u resolved it then Please let me know !!! It is a very interesting problem and owuld like to know the solution...
    Regards
    Krishna

  • How to create a letterpress card using iPhoto on my iMac?

    How to create a letterpress card using iPhoto on my iMac

    You CAN'T do it with Flash Player. You'd need Flash Professional and you'll need to learn Actionscript. I've been through the Lynda.com training for Flash, and it's not something you learn in a few minutes or even hours, or can be gleened from a guide. It takes days and possibly weeks, even if you're already good with Photoshop and/or Illustrator and Fireworks.

  • How do I prevent Spotlight from categorizing 'JAR' files as 'Application'

    I'm a java developer and consequently I have a lot of JAR files on the filesystem. The JAR file format is a standard archive format for java, and is used mostly to package library code - the java equivalent of a DLL. They can also be created as 'executable JAR's, but this is (very) infrequent compared to the library usage.
    Spotlight seems to think every JAR file is an application, and because I have a lot of java applications and development stuff installed, I can no longer reliably use Spotlight to find actual applications because the search results are overflowing with useless JAR file entries.
    Is there any way to configure spotlight to not classify JARS as applications? Or, alternately, can I make Spotlight ignore JARs completely? Either would save me a lot of time..
    /Bill

    There are several things in the current version of Spotlight that are either broken or just plain wrong. It looks like you have found another. When I look at the metadata for a jar file I see that its type is, well, a java jar file, and its content tree declares it to be a com.sun.java-archive. Finder gets this right: if you do GetInfo on such a jar file its kind is shown as "Java JAR file"--as it should be.
    When I made a saved search, using the Kind drop-down menu to get the pre-defined Application, and then looked to see what criteria Spotlight was using to define "application" (and yes, the search included jar files in its results), I discovered Spotlight was NOT using the simple, straightforward "kMDItemKind=Application" as one would expect. Instead it is using something I had never heard of to define an Application, to wit "_kMDItemGroupId = 8"--furthermore, I believe characterizing applications that way has been deprecated. Be that as it may, it doesn't work to find the things you want, and exclude the things you don't.
    There is no way for a user to fix this. The only thing you can do is not let Spotlight define the kind. Thus, if you bring up a search window do not use the Kind drop-down menu to select Application. Instead select Other from the menu and then type Application. You then get only things whose type declaration is Application, and you don't get jar files or widgets.
    The other option is to exclude jar files by typing
    NOT jar
    in the search for box (you'll still get widgets though). You can also add that boolean restriction if you are using the menu bar Spotlight search.
    Francine
    Francine
    Schwieder

  • Can't create a true ADF Libray JAR FIle

    I created a Model project. Then created an ADF Library JAR File Deployment Project to deploy the jar to the file system.
    I then, created a separate project and tried to add the export jar file to it via a File System connection in the Resource Palette.
    But, when I right click on the jar file in the Resource Palette, I only see 2 options, "Open" and "Advanced Search".
    I expected to have an option to add the jar to the selected project.
    Now, I am able to add the jar to the Project if I go to the projects properites, then add the jar via the "Libraries and Classpath".
    Note that even the icon for the jar is different than those from other System Jar files (the bookshelf/library icon).
    The icon I see for my jar is hard to identify, sort of like a torch.
    So, what is going on?
    I have double and triple checked that my deployment profile is for an "ADF Library JAR File".
    I have deleted the default deployment profile and create a brand new one.
    Still, the same issue.
    Any ideas?
    Thanks in advance.

    When you say you see the XML files for the EOs & VOs do you mean in the resource palette? Never mind, let's take a step back.
    Via the following link this is what you should see for a Model project ADF Library JAR that contains EO/VOs etc:
    https://dl.dropboxusercontent.com/u/12154176/pic01.png
    If you were to right click on the JAR this is what options you should see:
    https://dl.dropboxusercontent.com/u/12154176/pic02.png
    I'd suggest you're still doing something wrong when you create the ADF Library JAR. To assist you via this link:
    https://dl.dropboxusercontent.com/u/12154176/Model.zip
    ...you'll find a previous workspace/project I've setup. If you right click on the Model project look to the Deployment options you'll see an ADF Library deployment profile called "Model_Model_adflib". If you exit out of the preferences, right click Deploy -> select Model_Model_adflib, the appropriate ADF Lib JAR will be created under Model/Model/deploy. Returning to JDev and the Resource Palette, add a file system connection to this deploy directory, then you should see what I see above.
    Let us know how you go.
    CM.

  • Work with ADF Library jar file

    Hi
    My English isn't very good
    I use jdeveloper11.1.1.3.0
    I want to work with ADF Library jar file.
    I created two generic application. In each application I have a View Obj(one for employees table and one for department table ) and added them to App Module,
    then I made a ADF Library jar file for each application: adflib_emp, adflib_dep
    Then I created two separated application and in each application I created a BTF .
    In emp_TF1 I added adflib_emp jar file to application and in dep_TF2 I added adflib_dep jar file to application.
    These two applications work well. Then I created ADF Library jar file for each of these applications named: adflib_TF_1 and adflib_TF_2
    Finally I designed a main page to use these two jar file(adflib_TF_1 , adflib_TF_2). I added thses two jar file to application and then I dragged and dropped each TF to main page as a region:
    <af:panelSplitter id="ps1" splitterPosition="500">
    <f:facet name="first">
    <af:region value="#{bindings.emp_TF1.regionModel}" id="r1"/>
    </f:facet>
    <f:facet name="second">
    <af:region value="#{bindings.dep_TF2.regionModel}" id="r2"/>
    </f:facet>
    </af:panelSplitter>
    When I run main application both TF show employees table, but one TF should shows department table and the other one should shows employees table.
    I read oracle document and created my application on base of it. But I don't know why this happen and how to solve it?
    Habib
    Edited by: Habib Eslami on Apr 7, 2013 8:46 PM

    Hi,
    most likely the names of the application modules are not different but the same, which means you have a naming problem. Application modules (if they should be used as is) must have a unique name
    Frank

  • How to list all filename in excuteable jar file?

    Hi there,
    i've been googling around for hours, but found no good answer :(
    i want listing all file name in my excuteable jar file
    Firstly, i use
    File f = new File("/sounds");
    String[] filenames = f.list();
    and use these filenames to load some resouces from url
    //ex
    URL url = getClass().getResource("/sounds/"+filenames);
    No problem occurs when i run it normally
    but when I put it in excuteable jar file, NullPointerException appears
    i think it's because : "File f = new File("/sounds");" doesn't work in jar file (somehow, i don't know why too)
    is there any alternative way to listing all filename in this situation?
    thanks in advance

    There are jar handling classes in the standard library under java.util.jar. I think JarFile is the one you want.
    Hower it's not good practice to list jar contents in order to read resources. It's better to have some kind of resource file in the jar which lists your sounds or whatever. A simple text file with one file name per line suffices.

  • How to combine the classes from 2 jar files into 1?

    Hi there
    I have got 2 jar files with the same name but the classes that they contain are different. So, I want to combine those 2 files into 1. Could anyone please tell me how to add the classes in a jar file to another jar file?
    Thanks for your help!
    From
    Edmund

    The jar utility allows you to extract files as well as put them into a jar. This is in the java docs.
    You might have to hand modify the manifest file if it was hand modified in the first place. All you should have to do is copy the text from one file to another. The manifest will have the same name so you will have to extract to different dirs so it isn't overwritten.
    Steps:
    -Create dir1 and dir2
    -Extract jar1 into dir1, Extract jar2 into dir2.
    -Manually examine manifests and combine if needed.
    -Copy files from one dir to another.
    -Use jar tool to create new jar.

  • How to extract the contents of the Jar file?

    Hello,
    Can anyone tell me how to extract the contents of the Jar file?
    An example will be highly appreciated.
    Thanks.

    From command line, or from within a java application?
    Kaj
    Btw. Why do you need to do it. You do know that you can add jars to the classpath and read resources from them without extracting the file?

  • How to know if the current application jar file has been overwritten?

    When I overwrite a jar file that is being used, the buttons that call new windows stop responding silently but is there some check I can make from within the application to know if the jar file has been overwritten, so that I can warn the user to restart it?
    I know this sounds bad so let me explain why I would want this, if you don't care then skip everything below this point.
    I have close to a hundred of users executing Java applications from a central repository in the network. This is important because the applications are always changing and evolving so it's important that I only have to update one binary. I do most updates after work hours so I don't have a problem there but sometimes there are critical errors that need to be corrected immediately. Depending on the amount of people using an application it may be impractical to warn and wait for everyone to close it and make everyone else wait for that so I just overwrite the files that need to be updated and then warn everyone to restart the application. The result is that buttons that call for frames that haven't been called yet stop working silently. Some users already know what to do when that happens but I want a more graceful approach. I wanted to check for this situation from inside the application so that I could inform the user of the update and provide information on what to do next. Can I do this? I tried some try and catch blocks of code but I can't seem to catch anything when that happens.

    You can write your own class loader that loads classes from that jar file. Make sure it isn't on the class path and when you want to create an object from that jar file, call up your class loader to do that. (You only have to do that for your "top-level" objects, within those objects creating another object will automatically be done by your class loader.)
    Periodically check whether the jar has been modified. If it has, refresh the application by creating a new instance of your class loader and using that to create new instances of all your objects.
    But that sounds like a lot of work just to avoid setting up an emergency change procedure where you get everybody to close their applications.

  • How to rename the SharePoint Document Library existing file name using Web service

    Hi,
    How to rename the SharePoint Document Library existing file name using SharePoint Web service.
    Is it possible. How could i do it?
    Thanks & Regards
    Poomani Sankaran

    Hi,
    Lists.UpdateListItems Method
    would be helpful for your requirement.
    Here is a blog with code demo for your reference:
    http://blogs.msdn.com/b/knowledgecast/archive/2009/05/20/moss-using-the-list-web-service-to-rename-a-file.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • LR Flash web gallery

    I'm having a real problem with creating a flash web gallery in LR. I'm using LR 1.3 and firefox when I upload the gallery and go to view it in firefox it just hangs there saying "loading..." and it never loads. When I create a html gallery it works f

  • Problems w/ Project Manager

    Hello everyone, I'm working with adobe project manager and I'm running into a few issues. The purpose of using this at the local TV station where I work is to manage media and archive after a project's completion while still being able to go back in

  • Numbers '08 "If" with a greater or less than answer

    Hi all - I have a cell with a sum D & E28 (merged cell) that I want another cell B30 to display a value based on what is in cell D & E28. If cell D & E28 is 8 or less I want B30 to say 8. If D & E28 is greater than 8.001 but less than 12 I want B30 t

  • Java Linear, Quicksort, Binary Time Calc Problems

    Objective of program: Simple program demonstrating the time it takes to do each algorithm. My approach: 1) Prompt a number 2) Make array of linear ints 3) Calculate time it takes for a linear search 4) Repeat for quick sort, and Binary search Problem

  • Does the "Cubes" support error handling?

    Hi, I know that we can create fact and dimensions in OWB as "Dimension" and "Cube" . In a normal structure to populate the fact table we look up dimension to obtain the surrogate keys and then populate the fact table. If surrogate key is not found th