0

I'm trying to add Batik to a java project, I've downloaded 'batik-bin-1.8.zip' and added this to my project.

In my project tree I see:

Referenced Libraries
    batik-bin-1.8.zip

I can expand the contents of the zip to see the files, but this doesn't appear to expose the classes to the project.

I'm trying to get started using:

https://xmlgraphics.apache.org/batik/using/scripting/java.html

as a reference, however just declaring an instance of JSVGCanvas and then clicking on the icon to the left does not expose any packages to include.

What do I need to do?

SPlatten
  • 5,334
  • 11
  • 57
  • 128
  • 1
    You have to extract the zip file and add the jar files to your project – Jens Jan 19 '16 at 12:42
  • I just removed the zip reference, unpacked and then added external jar "batik-1.8.jar" – SPlatten Jan 19 '16 at 12:43
  • I would recommend that you use Maven to manage dependencies. If you insist on manually managing dependencies, you will need to extract the `.zip` to get all the individual `jar` files. You will then need to download any dependencies and treat them in the same way. You will then need to download any dependencies of those dependencies, and so forth until you have the entire graph. – Boris the Spider Jan 19 '16 at 12:43

1 Answers1

2

Manually adding the jars can become pretty tedious. You should set up your project with a build tool - like Gradle or Maven. Most popular Java libraries are available through Maven Central (although I personally prefer using this site to search for jars).

Modern IDEs (including Eclipse and IntelliJ) can import both Maven and Gradle projects, so it's just a matter of learning of either of these tools. (Or any other, for that matter.)

A minimal build.gradle file would look like this:

apply plugin: "java"
apply plugin: "eclipse"

sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]

dependencies {
  compile "some.company:lib-name:version"
}

You can import such project both as a Gradle project (in pretty much any modern Java IDE) or run gradle eclipse to generate Eclipse project data which can be imported as an "existing project".

Czyzby
  • 2,999
  • 1
  • 22
  • 40