Search code examples
javaubuntupackagebatik

Ubuntu 14.04, Eclipse 4.5.1, Java and Batik


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?


Solution

  • 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".