经过两天的努力,总于在ubuntu以下编译好classpath-0.98与jamvm1.5.4,并能成功的运行类文件:jamvm hellowold,当屏幕上打印出“hello world!”的时候,按捺不住一阵兴奋!在这两天中,运行jamvm hellowold始终被有三类异常:

1) Exceptionoccurred while VM initialising

java/lang/NoClassDefFoundError: java/lang/Thread

2) Exception occured while printing exception(java/lang/NoClassDefFoundError)...

Original exception wasjava/lang/UnsatisfiedLinkError

3)segment fault

对于当中异常1), 2) 我猜測可能是classpath等路径设错,我通过baidu,google,bing等搜索工具查询国内外相关问题,得出一个解决方法是:

通过jamvm –version 命令查询路径信息:

$ jamvm-version

javaversion "1.5.0"

JamVMversion 1.5.4

Copyright(C) 2003-2010 Robert Lougher <rob@jamvm.org.uk>

Thisprogram is free software; you can redistribute it and/or

modify itunder the terms of the GNU General Public License

aspublished by the Free Software Foundation; either version 2,

or (atyour option) any later version.

Thisprogram is distributed in the hope that it will be useful,

butWITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITYor FITNESS FOR A PARTICULAR PURPOSE.  Seethe

GNUGeneral Public License for more details.

Buildinformation:

ExecutionEngine: inline-threaded interpreter with stack-caching

Compiledwith: gcc 4.6.3

BootLibrary Path: /usr/local/classpath/lib/classpath

BootClass Path:

/usr/local/jamvm/share/jamvm/classes.zip:/usr/local/classpath/share/classpath/glibj.zip

在运行jamvm helloword之前须要设置两个变量:

export LD_LIBRARY_PATH=/usr/local/classpath/lib/classpath:$LD_LIBRARY_PATH

export  BOOTCLASSPATH=/usr/local/jamvm/share/jamvm/classes.zip:/usr/local/classpath/share/classpath/glibj.zip

可是我依照这样的方法来设置两个环境变量,还是解决不了问题;

关于异常3) 这个一定是jamvm本身的bug,除非单步调试,否则可能无法定位其问题,况且即使定位,也绝对无法解决。

在一筹莫展之时,突然搜索到一篇国际友人帖子,该贴对我的成功起了决定性的作用,真是山重水复疑无路,柳暗花明又一村!!!感谢该贴的作者!url例如以下:

http://www.webos-internals.org/wiki/Building_JamVM_and_GNU_Classpath_and_Jikes_(for_Java_support_in_webOS)_with_scratchbox2

详细来说,该文提到一个非常关键的地方,就是在编jamvm的时候,须要enable libffi模块,否则会引起段错误!

我依照该文的步骤,一步一步走下来,终于得到了自己想要的结果!该文的应该用场景是arm,而且能够带gui,gtk等应用,而我的应用场景比較简单,即在x86以下不带gui的应用,故而我的编译和他有一些区别,详细过程例如以下:

1.       classpath相关操作

$ cd ~/work/free

$ wget ftp://ftp.gnu.org/gnu/classpath/classpath-0.98.tar.gz

$ tar xzvf classpath-0.98.tar.gz

$ cd classpath-0.98

$ ./configure--disable-examples --without-x --disable-qt-peer --disable-gtk-peer--disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi

$ make -i

$ sudo make install -i

注: classpath的默认安装路径为/usr/local/classpath

2.       jamvm相关操作

$ cd ~/work/free

$ wget ftp://sourceware.org/pub/libffi/libffi-3.0.10.tar.gz

$ tar xzvf libffi-3.0.10.tar.gz

$ cd libffi-3.0.10

$ ./configure--prefix=/usr/local

$ make

$ sudo make install

$ sudo cp include/ffi_common.h /usr/local/include/

$cd i686-pc-linux-gnu/

$ cd include/

$ sudo cp ffi.h /usr/local/include

$ cd ../src/86

$ sudo cp ffitarget.h /usr/local/include

$ cd ~/work/free

$ wget http://freefr.dl.sourceforge.net/project/jamvm/jamvm/JamVM%201.5.4/jamvm-1.5.4.tar.gz

$ tar xzvf jamvm-1.5.4.tar.gz

$ cd jamvm-1.5.4

$ CPPFLAGS="-I/usr/local/include"

$ ./configure --with-classpath-install-dir=/usr/local/classpath -enable-ffi

$ make

$ sudo make install

3.       验证jamvm

1> 已知源码~/work/free/jamvm-1.5.4/java/helloworld.java:

public class helloworld {

    public static void main(String[] args) {

        System.out.println(“hello world!”);

    }

}

2> 编译 javac helloworld.java

生产helloworld.class

3> 运行jamvm helloworld 打印结果:

helloworld!

此时我们在查看CLASSPATH, LD_LIBRARY_PATH,发现:

lihan@master:~$echo $CLASSPATH

lihan@master:~$echo $LD_LIBRARY_PATH

:/usr/local/lib

cd ~/work/free/jamvm-1.5.4/java/

lihan@master:~/work/free/jamvm-1.5.4/java$jamvm helloworld

helloworld!

能够看到,CLASSPATH与LD_LIBRARY_PATH并不须要设置成之前说的, jamvm –version显示的那些路径!!!

最后,希望该文能对遇到相同问题的兄弟们起到一定帮助!

Ubuntu12.04下jamvm1.5.4+classpath-0.98成功执行 helloworld.class的更多相关文章

  1. 阿里云ubuntu12.04下安装使用mongodb

    阿里云ubuntu12.04下安装mongodb   apt-get install mongodb 阿里云ubuntu12.04下卸载mongodb,同时删除配置文件     apt-get pur ...

  2. [置顶] ubuntu12.04下编译opencv程序

    ubuntu12.04下编译opencv程序 1.在ubuntu下安装好 opencv后(建议使用apt-get install 来安装) 2.使用程序FaceExaple.c来进行测试程序 #inc ...

  3. ubuntu12.04下helloworld驱动从失败到成功过程

    最近在看linux的设备驱动程序,写一个简单的helloworld程序都花了我好久的时间,具体过程如下: 编写helloworld.c 编写Makefile 注意,makefile中的命令那里是一个t ...

  4. ubuntu12.04下NFS链接开发板并测试交叉编译的第一个应用

    思路:配置网络->安装NFS->配置NFS->挂载NFS服务->Down文件执行.Okay lets go! 配置网络: 在配置网络之前,首先咱得搞定与开发板的交互工作,那么这 ...

  5. Linux (Ubuntu12.04) 下开发工具安装和使用

    Linux (Ubuntu12.04) 下开发工具安装和使用 这里讲述的是关于在ubuntu12.04下面安装和使用各种IDE 开发环境和初步使用的知识.说一下背景:很多的开发基本都是在linux操作 ...

  6. 在ubuntu12.04下编译android4.1.2添加JNI层出现问题

    tiny4412学习者,在ubuntu12.04下编译android4.1.2添加JNI层出现问题: (虚心请教解决方法) trouble writing output: Too many metho ...

  7. Ubuntu16.04下编译安装OpenCV3.4.0(C++ & python)

    Ubuntu16.04下编译安装OpenCV3.4.0(C++ & python) 前提是已经安装了python2,python3 1)安装各种依赖库 sudo apt-get update ...

  8. Ubuntu12.04下安ns-3.29及Ubuntu换源方法

    目录 1.下载ns-3.29 2.安装gcc-4.9.2 3.编译.测试ns-3.29 第一种:更新,文章开头说的 第二种,更新源 主机型号:Ubuntu12.04 仿真环境版本:NS-3.29 安装 ...

  9. Ubuntu12.04下Qt连接MySQL数据库

    本文介绍在Ubuntu12.04 (64 bit) 下使用Qt 4.8.2连接MySQL(Ver 14.14 Distrib 5.5.43)数据库. 1.安装 Qt 和 MySQL 若未安装以上软件, ...

随机推荐

  1. 【后缀数组】【poj2774】【 Long Long Message】

    题意: 求两个串的最长连续子串. 我的想法: 枚举第二个串...在第一个串的后缀数组中二分查找. 复杂度NlogN.最坏情况N^2 题解: (3)height 数组:定义height[i]=suffi ...

  2. EF 事务处理 (InnoDB Engine的MySQL表也可以)

    备忘 1. 亲测(可以嵌套使用) using (TransactionScope scope = new TransactionScope()) { //操作1 XXEntities.Current. ...

  3. Foundation--NSArray+NSMutableArray

    C语言中数组只能存放一种类型 OC语言中数组可以存放多种类型,但是只能是对象类型,不可以是基本类型 我们实际中最好在一个数组中只存放一种类型的元素 nil表示数组的结尾,所以我们不能填写值为nil的对 ...

  4. ios 项目被拒绝各种理由

    . Terms and conditions(法律与条款) 1.1 As a developer of applications for the App Store you are bound by ...

  5. OpenGL教程之碰撞检测与模型运动

    下面我们要讨论的是如何快速有效的检测物体的碰撞和合乎物理法则的物体运动,先看一下我们要学的: 1)碰撞检测 ·移动的范围 — 平面 ·移动的范围 — 圆柱 ·移动的范围 — 运动的物体 2)符合物理规 ...

  6. 日志管理-将Log4net的配置配置到的独立文件中

    转自:http://www.cnblogs.com/zfanlong1314/p/3662679.html使用log4net已经很久了.但从来没有详情了解log4的参数,及具体使用方法.看了周公的博客 ...

  7. oracle 集合定义

    集合:是具有相同定义的元素的聚合.Oracle有两种类型的集合: 可变长数组(VARRAY):可以有任意数量的元素,但必须预先定义限制值. 嵌套表:视为表中之表,可以有任意数量的元素,不需要预先定义限 ...

  8. Turn the corner--hdu2438(3分法)

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

  9. fzu 1753 Another Easy Problem

    本题题意为求 t (t<150) 个 c (n,m)  (1<=m<=n<=100000)的最大公因子: 本题的难点为优化.主要有两个优化重点.一是每次对单个素因子进行处理,优 ...

  10. js里面“===”与“==”的区别

    首先,== equality 等同,=== identity 恒等. ==, 两边值类型不同的时候,要先进行类型转换,再比较. ==,不做类型转换,类型不同的一定不等.  下面分别说明: 先说 === ...