javac error when using jar file : cannot find symbol

Discussion in 'Java' started by powah, Mar 18, 2009.

  1. powah

    powah Guest

    I create the jar file MyJCESP.jar from MyWrapperAbstract.java &
    MyWrapperData.java.
    The DeriveKeyDemo.java use this jar file but compiling it result in
    the "cannot find symbol" error.
    Please help.

    //////////////////////////////
    // MyWrapperAbstract.java
    //////////////////////////////

    package com.mycomp.cryptox;

    import com.mycomp.crypto.*;

    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;

    public abstract class MyWrapperAbstract extends KeyGeneratorSpi {
    // ...
    }


    //////////////////////////////
    // MyWrapperData.java
    //////////////////////////////

    package com.mycomp.cryptox;

    import com.mycomp.crypto.*;

    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;

    abstract class MyWrapperData extends MyWrapperAbstract {
    // ...
    }

    MyWrapperAbstract.java & MyWrapperData are compiled to create the jar
    file MyJCESP.jar.


    //////////////////////////////
    // DeriveKeyDemo.java
    //////////////////////////////
    import java.io.*;
    import java.util.*;
    import java.security.*;
    import java.security.cert.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import javax.crypto.interfaces.*;

    import com.mycomp.cryptox.*; // Load MyJCEProvider classes
    import com.mycomp.crypto.*; // Load MyJCAProvider classes


    public class DeriveKeyDemo
    {
    public static void main(String[] args)
    {
    try
    {
    keyDerivator = MyWrapperData.getInstance("DES",
    "MyJCEProvider");
    keyDerivator.initialize(keyGen, 1024);

    // ...
    }
    }
    }

    CLASSPATH is setup as below:
    $ export CLASSPATH=/home/powah/jdk1.6.0_06/jre/lib/ext/MyJCASP.jar:/
    home/powah/jdk1.6.0_06/jre/lib/ext/MyJCESP.jar


    $ javac DeriveKeyDemo.java
    ^
    DeriveKeyDemo.java:94: cannot find symbol
    symbol : method getInstance(java.lang.String,java.lang.String)
    location: class com.mycomp.cryptox.MyWrapperData
    keyDerivator = MyWrapperData.getInstance("DES",
    "MyJCEProvider");
    ^
    DeriveKeyDemo.java:95: cannot find symbol
    symbol : method initialize(javax.crypto.KeyGenerator,int)
    location: class com.mycomp.cryptox.MyWrapperData
    keyDerivator.initialize(keyGen, 1024);
    ^
    2 errors
    powah, Mar 18, 2009
    #1
    1. Advertising

  2. powah

    Guest


    >
    > public class DeriveKeyDemo
    > {
    >       public static void main(String[] args)
    >       {
    >          try
    >          {
    >             keyDerivator = MyWrapperData.getInstance("DES",
    > "MyJCEProvider");
    >                 keyDerivator.initialize(keyGen, 1024);
    >
    >             // ...
    >          }
    >       }
    >
    > }
    >
    > CLASSPATH is setup as below:
    > $ export CLASSPATH=/home/powah/jdk1.6.0_06/jre/lib/ext/MyJCASP.jar:/
    > home/powah/jdk1.6.0_06/jre/lib/ext/MyJCESP.jar
    >
    > $ javac DeriveKeyDemo.java
    >          ^
    > DeriveKeyDemo.java:94: cannot find symbol
    > symbol  : method getInstance(java.lang.String,java.lang.String)
    > location: class com.mycomp.cryptox.MyWrapperData
    >             keyDerivator = MyWrapperData.getInstance("DES",
    > "MyJCEProvider");
    >                                                ^
    > DeriveKeyDemo.java:95: cannot find symbol
    > symbol  : method initialize(javax.crypto.KeyGenerator,int)
    > location: class com.mycomp.cryptox.MyWrapperData
    >                 keyDerivator.initialize(keyGen, 1024);
    >                             ^
    > 2 errors


    Where did you declare keyDerivator and keyGen?
    , Mar 18, 2009
    #2
    1. Advertising

  3. powah

    powah Guest

    On Mar 18, 3:53 pm, wrote:
    > > public class DeriveKeyDemo
    > > {
    > >       public static void main(String[] args)
    > >       {
    > >          try
    > >          {
    > >             keyDerivator = MyWrapperData.getInstance("DES",
    > > "MyJCEProvider");
    > >                 keyDerivator.initialize(keyGen, 1024);

    >
    > >             // ...
    > >          }
    > >       }

    >
    > > }

    >
    > > CLASSPATH is setup as below:
    > > $ export CLASSPATH=/home/powah/jdk1.6.0_06/jre/lib/ext/MyJCASP.jar:/
    > > home/powah/jdk1.6.0_06/jre/lib/ext/MyJCESP.jar

    >
    > > $ javac DeriveKeyDemo.java
    > >          ^
    > > DeriveKeyDemo.java:94: cannot find symbol
    > > symbol  : method getInstance(java.lang.String,java.lang.String)
    > > location: class com.mycomp.cryptox.MyWrapperData
    > >             keyDerivator = MyWrapperData.getInstance("DES",
    > > "MyJCEProvider");
    > >                                                ^
    > > DeriveKeyDemo.java:95: cannot find symbol
    > > symbol  : method initialize(javax.crypto.KeyGenerator,int)
    > > location: class com.mycomp.cryptox.MyWrapperData
    > >                 keyDerivator.initialize(keyGen, 1024);
    > >                             ^
    > > 2 errors

    >
    > Where did you declare keyDerivator and keyGen?


    They are declared as follows:
    //////////////////////////////
    // DeriveKeyDemo.java
    //////////////////////////////
    import java.io.*;
    import java.util.*;
    import java.security.*;
    import java.security.cert.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import javax.crypto.interfaces.*;

    import com.mycomp.cryptox.*; // Load MyJCEProvider classes
    import com.mycomp.crypto.*; // Load MyJCAProvider classes

    public class DeriveKeyDemo
    {
    public static void main(String[] args)
    {
    KeyGenerator keyGen = null;
    Key desKey = null;
    try
    {
    keyGen = KeyGenerator.getInstance("DES");
    desKey = keyGen.generateKey();

    // ...
    }
    catch (Exception e)
    {
    System.out.println("Exception during Key Generation - " +
    e.getMessage());
    System.exit(1);
    }

    MyWrapperData keyDerivator = null;
    try
    {
    keyDerivator = MyWrapperData.getInstance("DES",
    "MyJCEProvider");
    keyDerivator.initialize(keyGen, 1024);

    // ...
    }
    catch (Exception e)
    {
    System.out.println("Exception during Key Derivation - " +
    e.getMessage());
    System.exit(1);
    }
    }
    }
    powah, Mar 19, 2009
    #3
  4. powah

    Roedy Green Guest

    On Wed, 18 Mar 2009 12:28:01 -0700 (PDT), powah <>
    wrote, quoted or indirectly quoted someone who said :

    >I create the jar file MyJCESP.jar from MyWrapperAbstract.java &
    >MyWrapperData.java.


    Any jars you reference, the compiler needs on the classpath. You can
    put them in the ext directory if they are universally useful.

    see http://mindprod.com/jgloss/classpath.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    "In the central North Pacific, plastic outweighs surface zooplankton 6 to 1."
    ~ Thomas M. Kostigen
    Roedy Green, Mar 19, 2009
    #4
  5. powah

    Jon Gómez Guest

    Maybe your JAR isn't up to date, and contains a version without the
    methods in question?
    Jon.
    Jon Gómez, Mar 19, 2009
    #5
  6. powah

    Arne Vajhøj Guest

    Roedy Green wrote:
    > On Wed, 18 Mar 2009 12:28:01 -0700 (PDT), powah <>
    > wrote, quoted or indirectly quoted someone who said :
    >> I create the jar file MyJCESP.jar from MyWrapperAbstract.java &
    >> MyWrapperData.java.

    >
    > Any jars you reference, the compiler needs on the classpath. You can
    > put them in the ext directory if they are universally useful.


    That should be the absolutely last solution to try.

    It is the equivalent of copying windows dll's to C:\windows\system32.

    Arne
    Arne Vajhøj, Mar 22, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Alan Farrell
    Replies:
    6
    Views:
    9,676
    Andrew Thompson
    Jan 9, 2004
  2. hiwa
    Replies:
    1
    Views:
    1,564
    James Alan Farrell
    Jan 13, 2004
  3. Steve
    Replies:
    3
    Views:
    3,435
    Steve
    Jul 28, 2004
  4. Gabe
    Replies:
    3
    Views:
    1,059
  5. Replies:
    6
    Views:
    1,737
Loading...

Share This Page