How do I fully include the Batik library in my Java project? - java

I am trying to add the Batik library to my Java project. I added the unzipped binary to my lib folder, and added all of the JARs in the top level to the build path.
However, when I make the following import statement:
import org.apache.batik.dom.svg.SAXSVGDocumentFactory; I get the following error:
"The import org.apache.batik.dom.svg.SAXSVGDocumentFactory cannot be resolved"
Other import statements do not exhibit this problem, such as the following:
import org.apache.batik.util.XMLResourceDescriptor;
As far as I understand, the SAXSVGDocumentFactory class exist somewhere in the binary I added to the lib folder, so the issue must be with adding JARs to the build path. How can I make sure that all of the Batik source files are added to the build path correctly and are usable?

It cannot be resolved because it doesn't present in 1.8 jar. It exists in 1.7.
http://www.findjar.com/class/org/apache/batik/dom/svg/SAXSVGDocumentFactory.html
The easy way to find this out is to find the right jar and click to open it by the package: org.apache.batik.dom.svg.SAXSVGDocumentFactory. You wont see this class in 1.8 jar, but you will see it in 1.7 jar.
To fix, download a 1.7 jar and add it to your project again.
http://apache.mirrors.hoobly.com/xmlgraphics/batik/source/

If somebody can't find SAXSVGDocumentFactory after updating Batik in legacy project, just change the import:
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
with
import org.apache.batik.anim.dom.SAXSVGDocumentFactory;

Related

Importing vanilla Java project to use as a library in Android

I've written a piece of vanilla Java code to do a specific task. It contains a bunch of packages and resource files.
I want to import the vanilla Java project to Android to use some of its utilities.
I've tried to build my project to jar file, add it to the libs/ folder and import it. I've also tried to import it directly to the project dependencies. However, none of the above worked. The jar file showed up in the "External Library" part, but I cannot import it from a class inside as it gave me compilation error.
HERE you have plenty of ways how to attach jar to Android project
are you shure that your jar (assuming properly built) will work on Android? not all components and classes of "vanilla" Java are available on Googles OS... check out THIS topic for more info

JAR Creation Failed in Eclipse

I am using Eclipse Indigo, Jdk and Jre 1.8.
I have errors when creating JAR files like this :
Exported with compile errors: comX/com/abc/component/ext/common/StringUtil.java
Class files on classpath not found or not accessible for: comX/com/abc/component/logging/AsLog$QItem.java
At StringUtil.java I checked there are 2 imports that not resolved
import java.util.Arrays;
import org.apache.log4j.Logger;
--> Still don't know what the solution
And I already make sure that this file is exist: comX/com/abc/component/logging/AsLog$QItem.java
I already Clean and Build Project, but the errors is still.
Here is the JAR File Specification
And I check for this option in JAR Manifest Specification : Use existing manifest from workspace.
Any help will be very appreciated. Thank you.
-xtin-

Idea Intellij: Can't import the libraries: package does not exist

I'm trying to make use of a jReddit library, which, in turn requires apache HttpComponents and Commons IO libraries.
I downloaded the sources, added them in Itellij Idea through File - Project Structure - Modules - Add Content Root.
All the classes from the libraries that my code makes use of are imported successfully. But the problem appears when compiling - it says that package com.github.jreddit.oauth does not exist and package org.apache.http.impl.client does not exist and that it cannot find symbol of those libraries' classes.
Why does this happen and how to fix it?
Don't use Maven or Gradle if you can't even manage adding a JAR to your project manually.
You should acquire those JARs (containing .class byte code files, not .java source), add them a folder in your project named /lib, and add that directory as a JAR source location in your project. They'll be in the CLASSPATH then.
You need to add the /lib folder to an artifact when you run. Be sure you know how to do that as well.
I ran into this error after upgrading IntelliJ to version 2019.1. These steps fixed it for me:
Click Run from the toolbar
Choose Edit Configurations
Make sure the Scratch file you want to run is selected on the left panel
In Use classpath of module dropdown, select the project module that contains the proper module

How to add a new jarfile to eclipse project

I want to add new jar file to my project in eclipse. But when I trying Java build path ==> Add external Jars it makes a new library called referenced libraries.
So when I tried to import jfreechart1.0.1 it went to that library. So my import method is not working.
import org.jfree.data.xy.DefaultTableXYDataset;
Because jar file is not in JRE system library. Help me.
Try going to the projects properties, build path, and browse to it.

Android+Ant external jar library

I'd like to try org.apache.commons.lang.StringUtils in my Android project. I have downloaded commons-lang3-3.1.jar and placed it in my project's libs directory. However importing it fails with the library not being found. I have used many variations of
import org.apache.commons.lang.StringUtils;
with no success. My environment is the linux console and I'm using ant to compile, no Eclipse. My understanding is that Ant picks up any library in the project libs directory.
Please help. Android/java coding noob.
Lang 3.0 (and subsequent versions) use a different package (org.apache.commons.lang3) than the previous versions (org.apache.commons.lang), allowing it to be used at the same time as an earlier version. ref: http://commons.apache.org/lang/
import org.apache.commons.lang3.StringUtils;
Just put the jars in the libs/ directory. Silly me, I was putting them in the lib/ directory until I ran into the same issue and found the answer here:
How to build an android app with external libraries using ant?

Categories