aspose file tools*
The moose likes Beginning Java and the fly likes javac error when using jar file : cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javac error when using jar file : cannot find symbol" Watch "javac error when using jar file : cannot find symbol" New topic
Author

javac error when using jar file : cannot find symbol

Powah Wong
Greenhorn

Joined: Mar 18, 2009
Posts: 2
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.*;

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
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

First of all, please Use Code Tags.

Did you create these two methods? You've left out the bodies of these classes, so I can't check. I do know that they don't inherit these methods from KeyGeneratorSpi, so you will need to implement them.

Edit: I found the getInstance method inside class KeyGenerator, but that class has no direct relationship with KeyGeneratorSpi. As for a method called initialize that takes a KeyGenerator, there is none in the API.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Powah Wong
Greenhorn

Joined: Mar 18, 2009
Posts: 2
I create them.
What are the reasons that "javac error when using jar file : cannot find symbol"?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36563
    
  16
Which symbol can't it find? Where is it used?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac error when using jar file : cannot find symbol
 
Similar Threads
New to Java and trying to work with an existing app
Compiling servlets
Problem to compile servlet and Tomcat
Error compiling the AdviceClient.java
Exception in displaying data in a pdf format