The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

Hi, it's my understanding that if I want to use a JAR library from within my "Java in the Database" code, I need to include the directory which contains the JAR to my CLASSPATH environment variable. However, this doesn't seem to be working and I get NoClassDefFound errors.

I also tried extracting the JAR and setting the CLASSPATH to the root folder of the extracted JAR files, but still no luck.

It seems to work if I import every single class from the JAR into the database, but I would really prefer avoiding adding 2000+ classes to the database.

Shouldn't the CLASSPATH be used to resolve any missing class dependencies? What am I doing wrong?


asked 12 Dec '12, 09:39

glitch003's gravatar image

accept rate: 0%

You should not be putting the JAR in the classpath. Instead you should be installing the JAR right into the database. Please have a look at the INSTALL JAVA JAR statement.

permanent link

answered 12 Dec '12, 10:33

Karim%20Khamis's gravatar image

Karim Khamis
accept rate: 40%

Hi, when I try to install the JAR I get errors that classes are already present and the import fails. I can clearly see in Sybase Central > External Environments > Java > Classes that no classes are already present. So importing the JAR fails, and I had to import each class manually into the database.

It seems like you're telling me that Java in the Database can only see other classes that have been imported. Is that the case?

The documentation seems to imply that classes in the CLASSPATH can be used:

The Sun Java Runtime Environment and the Sun JDK Java compiler use the CLASSPATH environment variable to locate classes referenced within Java code. A CLASSPATH variable provides the link between Java code and the actual file path or URL location of the classes being referenced. For example, import* allows all the classes in the package to be referenced without a fully qualified name. Only the class name is required in the following Java code to use classes from the package. The CLASSPATH environment variable on the system where the Java class declaration is to be compiled must include the location of the Java directory, the root of the package.

(12 Dec '12, 10:48) glitch003

When you import a class using the IMPORT JAVA statement do you also get an error?

(12 Dec '12, 21:03) Derli Marcochi
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Dec '12, 09:39

question was seen: 649 times

last updated: 12 Dec '12, 21:03