0

I'm trying to compile a java program that is using JavaDB/Derby. On the command line I can run

java org.apache.derby.tools.sysinfo

without errors, but the following line in several of the files causes the error in my question title:

import org.apache.derby.client.am.SqlException;

causes

package org.apache.derby.client.am does not exist

I've done a fresh installation of JavaDB, but I don't think that matters. I've compiled this project once before, and I KNOW I didn't have JavaDB installed. I just had a directory at the top level of the project folder called lib with all of derby's .jar files inside. And I'm pretty sure I didn't have to set any environment variables either.

How can I fix this error? If I need to provide any more information, I will be happy to do so.

I'm using Windows 7 and jdk1.7

tvanc
  • 3,807
  • 3
  • 25
  • 40
  • 2
    Need to fix the question. Since the error is in javac, the java command is irrelevant. Check your classpath and if it still doesn't wokr, show the exact javac command. – RHT Nov 03 '11 at 00:03
  • 1
    `javac` needs to know where to look to find that package. You can specify it by setting the classpath. or using the `-cp` option – Hunter McMillen Nov 03 '11 at 00:06
  • 1
    Why are you trying to import the Derby version of SqlException. Perhaps you can just import java.sql.SqlException instead? – Bryan Pendleton Nov 04 '11 at 23:09

1 Answers1

1

Sounds like you have an issue with the JavaDB JARs not being on your classpath. Make sure you specify them using -cp or -classpath on your javac command.

Michael
  • 2,460
  • 3
  • 27
  • 47
  • If the files that need to be compiled are in com/company/project and the derby .jar files in lib (both relative to current directory), what should the -cp arg look like? I tried the following: javac -cp lib;com\company\project com\company\project\*.java javac -cp com\company\project com\company\project\*.java javac -cp lib com\company\project\*.java – tvanc Nov 03 '11 at 00:51
  • You would need to list each jar file separated by a semicolon (if you are on Linux/UNIX you would use a colon) So, you would do: javac -cp lib\jarFileName1.jar;lib\jarFileName2.jar com\company\project\*.java – Michael Nov 03 '11 at 00:53
  • I don't know the names of the specific JARs needed by JavaDB, but you should list them all instead of jarFileName1.jar and jarFileName2.jar – Michael Nov 03 '11 at 00:57
  • I did. Sorry, I should have replied, but had a lot of work to do. I tried using a wildcard to specify all of the .java files (-cp lib/*), but got an error saying derbyclient.java was an invalid flag. So I tried just derbyclient.java (-cp lib/derbyclient.java) and it worked. – tvanc Nov 05 '11 at 19:20
  • 1
    From my experience wildcards don't really work there. Glad it helped. – Michael Nov 06 '11 at 00:28