Pages

Sunday, April 13, 2014

Build an executable jar from a maven project

Not all the jar files are executable because there should be a well defined access point (public static void main(String[] args)) for a jar package to be executable.

Add the following plugin under plugins in your pom file. Eg: If I have my main method in class named, MainClass.java, I add the following.

<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <archive>
                <manifest>
                    <mainClass>MainClass</mainClass>
                </manifest>
            </archive>
          </configuration>
 </plugin>

Thursday, April 3, 2014

Package code with dependencies in Maven

1. Add the following part to the project pom file.

<build>
 <plugins>
  <plugin>
   <artifactId>maven-assembly-plugin</artifactId>
   <configuration>
    <descriptorRefs>
     <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
   </configuration>
  </plugin>

 </plugins>
</build>


2. package the code with the support of assembly plugin.

mvn clean package assembly:assembly 

3. This will generate two packages, one without dependencies and another with all the project dependencies. The latter is ready to be shipped directly.

Sunday, March 23, 2014

Arches data model and Core Data Standard(CDS)


The goal of this post is to explain the existing Arches data model and suggest a better data model fully based on standard data exchange models like XML or JSON. This should be referred as an extension to the GSoC 2014 proposal submitted by me(Tharindu Rusira) with the title "Data import/export improvements for Arches".

Arches Core Data Standard(CDS) handles the data model in Arches.The following section will explain the existing Arches data model.

Arches system concept glossary is here which defines 7 types of concepts.

Tuesday, March 11, 2014

Sphinx4 maven dependency

Sphinx4-1.0beta6 maven dependency is not available via maven central repository. But there is repository at ow2.org Sonatype nexus repositories[1] and we can add Sphinx4 to our project by modifying the pom.xml as follows.

Add repository location between <repositories></repositories>

<repository>
    <id>ow2 Legacy Releases</id>
    <url>http://repository.ow2.org/nexus/content/repositories/ow2-legacy/</url>

 </repository>

Now add the following dependency

<dependency>
  <groupId>edu.cmu.sphinx</groupId>
  <artifactId>sphinx4</artifactId>
  <version>1.0-beta6</version>
</dependency>


and you are done. Save pom.xml and build the project.

[1] http://repository.ow2.org/nexus/index.html#view-repositories


Friday, March 7, 2014

Stanbol Enhancement Engine fundamentals

The following steps will setup a new Stanbol enhancement engine and launch it as an OSGi bundle in Stanbol's integrated Apache Felix OSGi bundle management console.

1. Apache Stanbol defines 3 Maven archetypes that can be used in developing Stanbol components.
If Stanbol is built correctly, these three archetypes must be present in our local archetype catalog.
Check the presence of Stanbol archetypes.
cat ~/.m2/archetype-catalog.xml

If the file contains the following section, we are good to go with the rest of the process. The highlighted section is what we will be using for enhancement engines so we must at least have it.

<archetype>
      <groupId>org.apache.stanbol</groupId>
      <artifactId>statefull-webmodule-archetype</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <description>Archetype for a project that accesses the entityhub, and logs queries to a persisten graph</description

</archetype>
<archetype>
      <groupId>org.apache.stanbol</groupId>
      <artifactId>stateless-webmodule-archetype</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <description>Archetype for a project that allows posting files and shows the computed enhancements.</description>

</archetype>
<archetype>
      <groupId>org.apache.stanbol</groupId>
      <artifactId>enhancer-engine-archetype</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <description>Parent POM for the Apache Stanbol project</description>
</archetype>


Thursday, March 6, 2014

Remote debugging in Eclipse

Steps to debug a program running on a remote server

1. Launch the application(eg. xyz.jar) with Xdebug options 

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8345 -jar xyz.jar

Interpretation of these -Xrunjdwp properties are explained here[1] [2]

Fork me on GitHub