3 Replies Latest reply on Dec 17, 2008 6:52 PM by 843804

    Getting error when running the jar file..

    796542
      Hi All,

      I am new to executing jar file..Actually i have one class which contains the following code.
      *
      import com.documentum.fc.client.DfClient;
      
      **
      import com.documentum.fc.client.IDfClient;
      
      **
      import com.documentum.fc.client.IDfSession;
      
      **
      import com.documentum.fc.client.IDfSessionManager;
      
      **
      import com.documentum.fc.common.DfLoginInfo;
      
      **
      import com.documentum.fc.common.IDfLoginInfo;
      
      **
      import com.documentum.fc.common.DfException;
      
      **
      import com.fidelity.ftg.ereviewg2.migration.util.MigrationResource;
      
      *
      
       
      
      
      /**
      
      
      * This class is used for creating docbase connection
      
      
      * *@type* DocbaseConnection
      
      
      * *@author* a405304
      
      
      * *@see*
      
      
      */
      
      *
      public *class *DocbaseConnection {
      
      *
      
       
      
      
       
      
      
      //public static ResourceBundle resource;
      
      
       
      
      
      IDfSessionManager sMgr = *null*;
      
      
      IDfSession session = *null*;
      
      
      String docbaseName;
      
      
      *private* *static* DocbaseConnection +docbaseCon+;
      
      
       
      
      
      /**
      
      
      * Constructor for DocbaseConnection
      
      
      * *@throws* DfException
      
      
      * *@throws* Exception
      
      
      */
      
      
      *private* DocbaseConnection()*throws* DfException, Exception{
      
      
      //ResourceBundle bundle = ResourceBundle.getBundle(Constants.RESOURCE_PATH,Locale.getDefault());
      
      
      MigrationResource bundle = MigrationResource.+getBundle+();
      
      
       
      
      
      String userId = bundle.getString("DOCBASE_USERID");
      
      
      String password = bundle.getString("DOCBASE_PASSWORD");
      
      
      docbaseName = bundle.getString("DOCBASE_NAME");
      
      
       
      
      
      IDfClient client = DfClient.+getLocalClient+();
      
      
       
      
      
      sMgr = client.newSessionManager();
      
      
      IDfLoginInfo loginInfo = *new* DfLoginInfo();
      
      
      loginInfo.setUser( userId );
      
      
      loginInfo.setPassword( password );
      
      
      loginInfo.setDomain("");
      
      
      sMgr.setIdentity( docbaseName, loginInfo );
      
      
      session= sMgr.getSession( docbaseName );
      
      
      System.+out+.println("# Connected to Docbase: "+session);
      
      
      }
      Now i create the jar file whose name is docbaseconnection.jar

      Now when i am running this jar file by using the following command then i am getting the following error..

      C:\JAR_FILES>java -jar docbaseconnection.jar
      Exception in thread "main" java.lang.NoClassDefFoundError: com/documentum/fc/client/DfQuery

      For running this docbaseconnection.jar file i need the following thing in classpath...

      C:\Program Files\Documentum\dctm.jar;C:\Program Files\Documentum\Shared\dfc.jar;C:\Program Files\Documentum\Shared\log4j.jar

      I already add this jar files in the classpath of environment variables..Then also i am getting the same error..

      Kindly help me...........
        • 1. Re: Getting error when running the jar file..
          843804
          Since you want an executable jar file, you need to modify the manifest file, inside the META-INF folder of your jar.

          It should look like

          Manifest-Version: 1.0
          Main-Class: package.to.your.main.Class.MainClass (which seems to be com.documentum.fc.client.DfClient)
          Class-Path: dctm.jar dfc.jar allOtherJarLibraries.jar


          The path in the class-path is relative to your application. In the example I gave, you should keep them in the same directory as your app.
          • 2. Re: Getting error when running the jar file..
            796542

            The path in the class-path is relative to your application. In the example I gave, you should keep them in the same directory as your app.

            Hi I did not understand of the meaning of this one..

            Can you explain it briefly by giving one simple example. So its helpful to me..

            • 3. Re: Getting error when running the jar file..
              843804
              Well, let´s supose your manifest is defined as I did in my previous post. So, your directory base should be something like:

              C:\dir

              docbaseconnection.jar
              dctm.jar
              dfc.jar
              anotherlibraries.jar


              But, let´s supose you want something like
              C:\dir
              docbaseconnection.jar
              lib (folder, which contains dctm.jar, dfc.jar, etc)

              Then you should change the class-path of your manifest to

              Class-Path: ./lib/dctm.jar ./lib/dfc.jar


              That´s what I meant