Error opening a jar on the command line

2

I have the following code and I am using a library to list the citizen's card fields.

How much do I try to run in DOS does not work.

import java.io.*;
import pteidlib.*;
public class main {

        public String nome;
        public String data;
        public String pais;
        public String sexo;


        static
          {
            try
            {

                System.loadLibrary("pteidlibj");


            }
            catch (UnsatisfiedLinkError e)
            {
              System.err.println("Native code library failed to load.\n" + e);
              System.exit(1);
            }
          }


        public void PrintIDData(PTEID_ID idData) throws FileNotFoundException, UnsupportedEncodingException
          {
                nome = idData.firstname + " " + idData.name ;
                data =  idData.birthDate;
                pais = idData.country;
                sexo = idData.sex;
                    PrintWriter writer = new PrintWriter("the-file-name.txt", "UTF-8");

           writer.println(nome);   
            writer.println(data);
            writer.close();
                System.out.print(nome);
          }


    public static void main(String[] args) throws UnsupportedEncodingException, FileNotFoundException, PteidException{
              main  test = new main();

           pteid.Init("");
      //test.TestChangeAddress();
        // Don't check the integrity of the ID, address and photo (!)
      pteid.SetSODChecking(false);

      int cardtype = pteid.GetCardType();
      switch (cardtype)
      {
          case pteid.CARD_TYPE_IAS07:
              System.out.println("IAS 0.7 card\n");
              break;
          case pteid.CARD_TYPE_IAS101:
              System.out.println("IAS 1.0.1 card\n");
              break;
          case pteid.CARD_TYPE_ERR:
              System.out.println("Unable to get the card type\n");
              break;
          default:
              System.out.println("Unknown card type\n");
      }

      // Read ID Data
      PTEID_ID idData = pteid.GetID();
      if (null != idData)
      {
        test.PrintIDData(idData);
      }


}
}

I need to run this on the command line java -cp test.jar main so after being called on the command line give me this error:

    
asked by anonymous 01.10.2015 / 13:19

1 answer

2

Adding to @ user2964140's response, and assuming the library is in c: \ as you said, the command to execute should be:

java -cp .;c:\suabiblioteca.jar -jar test.jar

This response assumes that your jar test.jar was done correctly (that is, it includes a MANIFEST.MF with the header that talks about which class contains your public static void main(String args[]) method.) If this is not the case, it is advisable to read Oracle's tutorials on creating jars and manifest files.

One last suggestion is to include your library in the lib/ directory within your jar, so that your application contains everything you need.

    
04.01.2016 / 07:06