javac error when using jar file : cannot find symbol

P

powah

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
 
L

lord.zoltar

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?
 
P

powah

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);
}
}
}
 
J

Jon Gómez

Maybe your JAR isn't up to date, and contains a version without the
methods in question?
Jon.
 
A

Arne Vajhøj

Roedy said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top