[Biojava-l] How to compile and run the demo in biojava3?

Peng Yu pengyu.ut at gmail.com
Tue Jul 23 16:17:24 UTC 2013


Hi,

I can't figure out how to use IDE with biojava as shown in other
emails in the thread.

But I copied DecoCE.java to a new project (created by 'mvn
archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false').

~/linux/test/java/maven/bin/mvn/my-app$ ll
src/main/java/com/mycompany/app/DemoCE.java
-rw-r--r-- 1 py staff 3930 2013-07-23 00:23:44
src/main/java/com/mycompany/app/DemoCE.java

The pom.xml is the following. I then compiled the package and run
DemoCE. But it failed. Does anybody know what is wrong? Thanks.

~/linux/test/java/maven/bin/mvn/my-app$ cat 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>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>my-app</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.biojava</groupId>
      <artifactId>biojava3-core</artifactId>
      <version>3.0.6</version>
    </dependency>
    <dependency>
      <groupId>org.biojava</groupId>
      <artifactId>biojava3-structure</artifactId>
      <version>3.0.6</version>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <id>biojava-maven-repo</id>
      <name>BioJava repository</name>
      <url>http://www.biojava.org/download/maven/</url>
    </repository>
  </repositories>
</project>

~/linux/test/java/maven/bin/mvn/my-app$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources)
@ my-app ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory
/Users/py/linux/test/java/maven/bin/mvn/my-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ my-app ---
[WARNING] File encoding has not been set, using platform encoding
MacRoman, i.e. build is platform dependent!
[INFO] Compiling 3 source files to
/Users/py/linux/test/java/maven/bin/mvn/my-app/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources
(default-testResources) @ my-app ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory
/Users/py/linux/test/java/maven/bin/mvn/my-app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile
(default-testCompile) @ my-app ---
[WARNING] File encoding has not been set, using platform encoding
MacRoman, i.e. build is platform dependent!
[INFO] Compiling 1 source file to
/Users/py/linux/test/java/maven/bin/mvn/my-app/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ my-app ---
[INFO] Surefire report directory:
/Users/py/linux/test/java/maven/bin/mvn/my-app/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.mycompany.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ my-app ---
[INFO] Building jar:
/Users/py/linux/test/java/maven/bin/mvn/my-app/target/my-app-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.838s
[INFO] Finished at: Tue Jul 23 11:15:30 CDT 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------

~/linux/test/java/maven/bin/mvn/my-app$ java -cp
target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.DemoCE
Exception in thread "main" java.lang.NoClassDefFoundError:
org/biojava/bio/structure/align/util/AtomCache
	at com.mycompany.app.DemoCE.main(DemoCE.java:36)
Caused by: java.lang.ClassNotFoundException:
org.biojava.bio.structure.align.util.AtomCache
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 1 more

On Mon, Jul 22, 2013 at 11:25 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> Hi,
>
> I see some demos in biojava3 source repository.
>
> ~/dvcs_src/biojava/biojava3-alignment/src/main/java/demo$ dir
> CookbookMSA.java  DemoAlignProteins.java  DemoLoadSubstMax.java
> TestDNANeedlemanWunsch.java
>
> I just learned how to use mvn to start a new project and added biojava
> info to pom.xml as in the following. But I'm not sure how to compile
> the demo and run it. Could anybody show the detailed procedure on how
> to use them? Thanks.
>
> ~/linux/test/java/maven/bin/mvn/my-app$ cat 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>com.mycompany.app</groupId>
>   <artifactId>my-app</artifactId>
>   <packaging>jar</packaging>
>   <version>1.0-SNAPSHOT</version>
>   <name>my-app</name>
>   <url>http://maven.apache.org</url>
>   <dependencies>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>3.8.1</version>
>       <scope>test</scope>
>     </dependency>
>     <dependency>
>       <groupId>org.biojava</groupId>
>       <artifactId>biojava3-core</artifactId>
>       <version>3.0.6</version>
>     </dependency>
>   </dependencies>
>   <repositories>
>     <repository>
>       <id>biojava-maven-repo</id>
>       <name>BioJava repository</name>
>       <url>http://www.biojava.org/download/maven/</url>
>     </repository>
>   </repositories>
> </project>
>
> --
> Regards,
> Peng



-- 
Regards,
Peng



More information about the Biojava-l mailing list