Ubuntu & Java

Aus Peter Fuerholz' Wiki
Zur Navigation springen Zur Suche springen

Java

Install Java 8 on Ubuntu Mate Download JDK from Oracle and choose the 'Linux x86' variant.


Older variant: Installing Java 8 (9) on Ubuntu 14.04LTS

  • Starting from Ubuntu 10.04 LTS Canonical prioritizes the use of OpenJDK. To use the Sun (Oracle) JDK you have to call: add-apt-repository "deb http://archive.canonical.com/ lucid partner", see [1] for more information.
  • Configure which Java to use with: sudo update-alternatives --config java
    Do the same for: idlj, jar, jarsigner, javac, javadoc, javah, javap, javaws, jconsole, jdb, jexec, jhat, jinfo, jmap, jps, jrunscript, jsadebugd, jstack, jstat, jstatd, keytool, native2ascii, orbd, pack200, policytool, rmic, rmid, rmiregistry, schemagen, serialver, servertool, tnameserv, unpack200, wsgen, wsimport, xjc
  • sudo update-alternatives --config java to update JAVA_HOME variable
  • Save and restart PC

Ant

Ant can be installed via package manager. If you have already installed Eclipse, Ant got installed too.

Ant-Contrib

  • If you need ant-contrib do the following:
  1. Download ant-contrib [2]
  2. sudo cp /home/pfu/download/ant-contrib/lib/ant-contrib.jar /usr/share/java/ant-contrib-1.0b2.jar
  3. Zip documentation (select in Nautilus, right-mouse-click: archive) and copy it to same destination:
sudo cp /home/pfu/download/ant-contrib/lib/ant-contrib-docs.zip /usr/share/java/ant-contrib-1.0b2-docs.jar

Maven

Install: Download tar.gz file, then:

tar -xvf <tar.gz-file>
sudo /usr/local/apache-maven
sudo mv apache-maven /usr/local/apache-maven

Edit local /etc/environment:

export M2_HOME=/usr/local/apache-maven/apache-maven-<version>
export M2=$MS_HOME/bin

+ update PATH (export PATH=$M2:$PATH works only on the shell command but not in environment-file).

Ivy

Ivy is like Maven an Apache project. In comparison to Maven, Ivy:

  • has only dependency management on its topic
  • is more lightweight
  • fits well with ANT (not a replacement)

I (try to use) am using Ivy for following reasons:

  • I am quite happy with the common Eclipse features. Maven makes versioning of own projects more complicate than needed.
  • Ivy just helps me including the bunch of necessary libraries. Currently I am happy with this.
  • Vaadin comes with it.

Helpful links:

IvyIDE

IvyIDE the Eclipse plugin
Plugin to help in Eclipse
Using multiple projects
With IvyIDE it is possible to refer between Eclipse project. That means you don't need to create the artifacts (jars) between the projects. For this to work you have to fill out the ivy.xml files properly (organisation / name / version) and refer to it properly (you can use 'latest' as a placeholder for 'no version'). Unfortunately this does not work for Web (WTP) projects (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=184125). In my experience follwing workaround helps: Refer to the other project via 'Properties', 'Deployment Assembly', 'Add...', 'Project', then select your project, OK, OK.

There is no specific Ivy project type. To use Ivy in your Eclipse project just right click on your project, 'Configure', 'Add Ivy dependency management', Ok. Then add your ivy.xml file. If something does not work properly:

  • Open/close project (or)
  • Right-mouse click, 'Ivy', 'Resolve' / 'Refresh)