hello world

          隨筆 - 2, 文章 - 63, 評論 - 0, 引用 - 0
          數據加載中……

          linux嵌入式下安裝java運行環境

          java?version? " 1.5.0 "
          JamVM?version?
          1.5 . 4
          Copyright?(C)?
          2003 - 2010 ?Robert?Lougher? < rob@jamvm.org.uk >

          This?program?
          is ?free?software;?you?can?redistribute?it? and / or
          modify?it?under?the?terms?of?the?GNU?General?
          Public ?License
          as ?published?by?the?Free?Software?Foundation;?either?version? 2 ,
          or ?(at?your? option )?any?later?version.

          This?program?
          is ?distributed?in?the?hope?that?it?will?be?useful,
          but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
          MERCHANTABILITY?
          or ?FITNESS? FOR ?A?PARTICULAR?PURPOSE.??See?the
          GNU?General?
          Public ?License? for ?more?details.

          Build?information:

          Execution?Engine:?direct
          - threaded?interpreter? with ?stack - caching
          Compiled?
          with :?gcc? 4.6 . 2 ? 20110630 ?(prerelease)

          Boot?Library?Path:?
          / usr / classpath / lib / classpath
          Boot?Class?Path:?
          / usr / jamvm / share / jamvm / classes.zip: / usr / classpath / share / classpath / glibj.zip
          交叉編譯環境前提已經搭建好

          各個軟件版本及下載地址:
          ?????? GNU Classpath 0.98? http://www.gnu.org/software/classpath/downloads/downloads.html
          ?????? JVM 1.54? https://sourceforge.net/projects/jamvm/files/jamvm/
          ?????? zlib? 1.2.11 http://www.zlib.net/
          ?????? libffi 3.2 ftp://sourceware.org/pub/libffi/

          編譯過程:
          ?一、編譯gnu classpath
          ???????? 前提:
          ???????? 1、在/usr下創建classpath文件夾,并賦予權限 :sudo chmod 777 /usr/classpath -R
          ???????? 2、將文件解壓并將文件夾賦予權限 sudo chmod 777 ~/software/classpath-0.98 -R
          ???????? 編譯安裝:
          ???????? 1、./configure --prefix=/usr/javatools --host=arm-none-linux-gnueabi --disable-examples --without-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi --disable-Werror --disable-tools
          ?????????
          ????????? 說明:直接執行,會報錯conditional "GCJ_JAVAC" was never defined.
          ?????????? 根據百度的結果,解決方式是假設
          GCJ沒有定義,但是它也沒有用到過,則就在.configure文件中把那個if判斷用#屏蔽了
          ???????? 2、make & make install
          ?
          二、編譯zlib
          ???????? 前提:
          ????????? 1、在/usr下創建zlib文件夾,并賦予權限:sudo chmod 777 /usr/zlib -R
          ????????? 2、將文件解壓并將文件夾賦予權限:sudo chmod 777 ~/software/zlib-1.2.11 -R
          ????????? 編譯安裝:
          ????????? 1、
          ??????????????? export CC=arm-linux-gcc
          ??????????????? ./configure --prefix=/usr/zlib
          ?????????? 2、make & make install

          三、編譯libffi
          ???????? 前提:
          ????????? 1、將libffi同樣安裝在/usr/zlib文件夾下
          ????????? 2、將文件解壓并將文件夾賦予權限:sudo chmod 777 ~/software/libffi-3.2 -R

          ????????? 編譯安裝:
          ????????? 1、./configure --prefix=/usr/zlib --host=arm-none-linux-gnueabi
          ????????? 2、make & make install

          ????????? 拷貝文件:
          ???? 將/usr/zlib/lib/libffi-3.2/include/ ?將里面的ffi.h ffitarget.h 復制到/usr/zlib/include中。

          四、編譯jvm
          ??????????
          ???????? 前提:
          ????????? 1、在/usr下創建jamvm文件夾,并賦予權限:sudo chmod 777 /usr/jamvm -R
          ????????? 2、將文件解壓并將文件夾賦予權限:sudo chmod 777 ~/software/jamvm-1.54 -R

          ????????? 編譯安裝:
          ????????? 1、./configure --prefix=/usr/jamvm --with-classpath-install-dir=/usr/classpath --enable-ffi --disable-int-inlining --host=arm-none-linux-gnueabi CFLAGS=-I/usr/zlib/include LDFLAGS=-L/usr/zlib/lib
          ?????????? 2、make & make install

          安裝到開發板并配置環境變量

          ????????? 1、classpathjamvm兩個文件夾復制到開發板的 /usr目錄下面

          ???? 2、將zlib/lib中的所有文件夾和文件拷貝到開發板的/usr/lib/目錄下面

          ???? 3、配置環境變量
          ??????????
          export PATH=$PATH:/usr/jamvm/bin

          ?????????????????????? jamvm -version
          打印版本信息如下:
          java?version?"1.5.0"
          JamVM?version?
          1.5.4
          Copyright?(C)?
          2003-2010?Robert?Lougher?<rob@jamvm.org.uk>

          This?program?
          is?free?software;?you?can?redistribute?it?and/or
          modify?it?under?the?terms?of?the?GNU?General?
          Public?License
          as?published?by?the?Free?Software?Foundation;?either?version?2,
          or?(at?your?option)?any?later?version.

          This?program?
          is?distributed?in?the?hope?that?it?will?be?useful,
          but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
          MERCHANTABILITY?
          or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
          GNU?General?
          Public?License?for?more?details.

          Build?information:

          Execution?Engine:?direct
          -threaded?interpreter?with?stack-caching
          Compiled?
          with:?gcc?4.6.2?20110630?(prerelease)

          Boot?Library?Path:?
          /usr/classpath/lib/classpath
          Boot?Class?Path:?
          /usr/jamvm/share/jamvm/classes.zip:/usr/classpath/share/classpath/glibj.zip
          ?????????????????????? 將紅色部分設置到環境變量中:

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

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

          ?????????????????????? 該命令可以每次都執行一次,也可以寫到開發板的啟動文件中,這樣就不用每次都手動執行。啟動文件不同開發板不一樣,自己去添加環境變量,此處不再敘述。

          java程序:
          ?????
          public?class?HelloWorld?{
          ????
          public?static?void?main(String[]?args){
          ????????System.out.println(
          "Hello?World!");
          ????}
          }

          ?????? 編譯 javac HelloWorld
          ?????? 將生成的HelloWorld.class拷貝到開發板上執行jamvm HelloWorld
          ?????? 打印Hello World!



          遇到的問題:
          ??????? 1、執行config和make主要是三類問題,沒有執行權限,利用chmod 777 將文件夾所有權限賦值;缺少依賴庫,主要是zlib和ffi,下載安裝即可;config配置錯誤,按照當前的沒有問題;
          ??????? 2、庫拷貝問題,zlib/lib庫未拷貝,會產生找不到lib庫的問題;
          ??????? 3、執行的時候還報如下錯誤,可能三種原因導致:環境變量設置錯誤;classpath和jamvm版本不正確;java程序的位置不對。
          ????????????????? Exceptionoccurred while VM initialising
          ????????????????? Java/lang/NoClassDefFoundError: java/lang/Thread
          ??????? 4、之前試了classpath0.99和jamvm2.0.0,一直報第三個錯誤,直到變成當前的版本,坑啊!
          ??????? 5、java程序的位置不要定義包就好了。
          ??????????

          posted on 2017-04-26 17:25 聽風 閱讀(1305) 評論(0)  編輯  收藏 所屬分類: JAVA

          主站蜘蛛池模板: 岢岚县| 武鸣县| 赣州市| 蓬莱市| 塘沽区| 会泽县| 香港 | 镇原县| 漾濞| 隆化县| 澄江县| 萨嘎县| 邵阳市| 东安县| 玉环县| 兴隆县| 尼木县| 定陶县| 珲春市| 延川县| 平潭县| 永川市| 正镶白旗| 富宁县| 呼伦贝尔市| 罗甸县| 张家港市| 城口县| 哈巴河县| 依兰县| 浦东新区| 吉安县| 濮阳市| 博白县| 衡阳市| 庆安县| 肥西县| 九江市| 科尔| 松滋市| 通城县|