Archive

Posts Tagged ‘java’

Rails and Emacs: Rsense and Auto-Complete

2011/07/17 Comments off

If you’re developing Rails with Emacs and using Rinari here are two more extensions you might like:

http://cx4a.org/software/auto-complete/

and

http://cx4a.org/software/rsense/

Installation. Just  as described. Code completion for ruby-on-rails with emacs!

And the package is written in Java(!), Very cool!

I am impressed!

Maven Error: generics are not supported in source 1.3

2009/06/22 2 comments

Just stumbled across this error while trying to compile a simple Java Maven project:

Maven Error: generics are not supported in source 1.3

It turns out that maven uses the Java compiler 1.3 (!) by default. So you have to add the configuration settings to your pom.xml file…

See Hobione’s Blog entry on the same issue.

My HelloWorld script for Maven

2009/06/15 2 comments

I’m still in the learning phase of using Maven, so bare with me. Here is my script to create an executable HelloWorld-jar file using Maven (it requires the file sample-pom.xml listed after the script):

#!/bin/bash
#
# Description: Create a simple Java project using Maven.
#
# Status: Works
#
# Author: draptik
#
# Created: Mon Jun 15 21:17:24 2009
#
# REQUIREMENTS
# ============
#
# 1. Maven
#
# 2. This script requires the file "sample-pom.xml"!!!
#
# 3. The "sample-pom.xml" file should be located in the same folder as
# this script.
#
# USAGE
# =====
#
# 1. Copy this script and "sample-pom.xml" to a newly created test
# folder (ie ~/tmp/maventesting/).
#
# 2. Run this script
#
# DETAILS
# =======
#
# This script creates a "quickstart" Maven project, then overwrites
# the created pom.xml with something more sensible (including some
# useful Maven plugins), and runs "java -jar <your-program>.jar".

## User settings
companyName="org.foo"
appName="my-app"

## Static file
samplePom="sample-pom.xml"
pdinfo="[PDINFO] "

## Delete old builds
echo "$pdinfo" "====== REMOVING PREVIOUS BUILDS ====================="
echo "$pdinfo" "rm -rf \"$appName\""
rm -rf "$appName"

## Create Maven skeleton
##
## NOTE: You can exchange the first 2 lines with:
##
## mvn archetype:create \
##         -DarchetypeGroupId=org.apache.maven.archetypes \
##
## This will result in a warning that "archetype:create" is
## deprecated. The warning states that you should use
## "archetype:generate". This archetype is interactive by default. To
## skip the interactive part and choose the default (="quickstart")
## you have to pass the option "-Dinteractive=false" to Maven.
echo "$pdinfo" "====== MAVEN CREATION ================================"
echo "$pdinfo" ""
mvn archetype:generate \
	-DinteractiveMode=false \
	-DarchetypeGroupId=org.apache.maven.archetypes \
	-DgroupId="$companyName" \
	-DartifactId="$appName"

## Show the diff between generated pom.xml and sample-pom.xml
echo "$pdinfo" "====== DIFF BETWEEN GENERATED AND MY POM.XML ========"
echo "$pdinfo" "diff -u \"$appName\"/pom.xml \"$samplePom\" "
diff -u "$appName"/pom.xml "$samplePom" 

## Overwrite generated pom.xml
echo "$pdinfo" "====== OVERWRITING GENERATED POM.XML ================"
echo "$pdinfo" "cp  \"$samplePom\" \"$appName\"/pom.xml"
cp  "$samplePom" "$appName"/pom.xml

## Move to newly created project
cd "$appName"

## Make an executable jar file
echo "$pdinfo" "====== MAKING THE FINAL JAR FILE ===================="
echo "$pdinfo" "mvn package"
mvn package

## Move to target folder
cd target

## Run the Hello-World example
echo "$pdinfo" "====== TESTING THE JAR FILE =========================="
echo "$pdinfo" "java -jar $appName-1.0-SNAPSHOT.jar..."
echo "$pdinfo" "If the next line does not read \"Hello World!\", something is wrong"
java -jar "$appName"-1.0-SNAPSHOT.jar

Here is the file sample-pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.foo</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>my-app</name>
  <url>http://maven.apache.org</url>
  <build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <archive>
        <manifest>
          <addClasspath>true</addClasspath>
          <mainClass>org.foo.App</mainClass>
        </manifest>
      </archive>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
  </plugin>
</plugins>
</build>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
Categories: IT, linux, windows Tags: , , , , ,

Maven-eclipse-plugin 2.6 might break wicket projects

2009/06/13 Comments off

Took me a while to find this, so I thought I’ll post it: Maven’s eclipse plugin version 2.6 does not work well with Wicket projects.

The problem with version 2.6 is that the Maven’s folder structure does not conform to Wicket’s folder structure. This seems to be fixed in version 2.7. Alternatively, you can use Maven-eclipse-plugin version 2.5.1.

See Martijn Dashorst’s blog and this thread on the wicket-user mailing list for details.

In short: If your pom.xml file contains

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.6</version>
</plugin>

replace it with this

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.5.1</version>
</plugin>

Maven2 Heap Overflow in JUnit test cases: Howto increase memory

2009/05/22 6 comments

For the past few days I was wondering why Maven’s install gave me a Heap Overflow exception on JUnit tests on some of my machines. I tried increasing the memory by using the environment variable MAVEN_OPTS, by passing the option “-Xmx512m” to the JVM through Eclipse and from the command line. All to no avail.

Then I found this blog entry by Keith Chapman. And it worked! Here’s the solution in short:

The JUnit tests ignore the environment variable MAVEN_OPTS. You have to tell Maven’s surefire plugin to increase memory. Add this to your pom.xml file:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <forkMode>pertest</forkMode>
    <argLine>-Xms512m -Xmx512m</argLine>
    <testFailureIgnore>false</testFailureIgnore>
    <skip>false</skip>
  </configuration>
</plugin>

From 8.04 LTS to Jaunty Jackalone (Ubuntu 9.04): Software

2009/04/28 4 comments

The upgrade from the Ubuntu 8.04 LTS version to 9.04 (codename “Jaunty Jackalone” = JJ) was very smooth. It did NOT screw up the X-Server, SMB, Cups, NFS, SSH, USB, etc.  For me it was about a 3GB download.

The first thing I noticed was that a nasty gdm-login-screen-resolution bug was fixed by upgrading from 8.04 to 8.10.

Since each upgrade changes the default version of ones most used/favorite software, I will list those products I was concerned about most:

Sun Java (http://java.sun.com/)

  • OK: JJ comes with the current Java JRE and SDK version (1.6_13)

Eclipse (http://www.eclipse.org/)

  • Out-of-date: JJ comes with version 3.2 (2 years old). The current version is 3.4 (Ganymede). But since you can run Eclipse directly without compiling, this is no big deal.

GNU Emacs (http://www.gnu.org/software/emacs/)

  • GNU Emacs snapshot (=bleeding edge/developer version): OK: installing emacs-snapshot-gtk gives a current developer version  (build from 2009-04-05)
  • Emacs stable: Out-of-date: The current Emacs version is 22.3. JJ has Emacs version 22.2, although Emacs 22.3 was released 2008/09.

AUCTeX (http://www.gnu.org/software/auctex/)

  • Out-of-date: JJ comes with AUCTeX version 11.84. Version 11.85 was released 2008/02. I’ll have to install this manually.

R (http://www.r-project.org/)

  • OK: JJ has 2.9.0. The current version is 2.9.0.

TexLive (http://www.tug.org/texlive/)

  • Out-of-date: JJ comes with texlive-2007… Just download the current texlive-2008 from the texlive homepage and install it beside the Ubuntu texlive version.

Skype-Plugin for Pidgin’s Instant Messenger

  • I’ve already written a blog on some of the nice Pidgin features. After upgrading to JJ and seeing that Pidgin is used for internal messaging within Ubuntu, I am even more convinced that this is currently THE multi-protocol multi-plattform instant messenger to go with. Get the skype-plugin from http://eion.robbmob.com/ and install the Debian/Ubuntu skype4pidgin.deb file by executing “sudo dpkg -i skype4pidgin.deb”

GTKtalog (http://www.nongnu.org/gtktalog/)

  • Not present in JJ’s repositories. I’m very sad about this, because to my knowledge this is the only software for managing a CD/DVD collection which does not require a database. Although its user interface (Tck/Tk) is not-so-stylish-up-to-date, it has many features which I have grown accostumed to and which are lacking even in current high-end Disk-Manager programs.
Follow

Get every new post delivered to your Inbox.