Ubuntu12.04 under jamvm1.5.4+classpath-0.98 successful execution Helloworld.class

Source: Internet
Author: User
Tags ffi gtk

After two days of effort, always in the following Ubuntu compiled classpath-0.98 and jamvm1.5.4, and can successfully run the class file: Jamvm hellowold, when the screen print "Hello world!" Time, can't restrain a burst of excitement! During these two days, running JAMVM Hellowold always has three types of exceptions:

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

For the exception of the 1), 2) I guess the test may be classpath and other path error, I through the baidu,google,bing and other search tools to query domestic and foreign related issues, to arrive at a solution is:

To query the path information with the Jamvm–version command:

$ jamvm-version

Javaversion "1.5.0"

Jamvmversion 1.5.4

Copyright (C) 2003-2010 Robert lougher <[email protected]>

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'll 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

You need to set two variables before running 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

But I follow this method to set up two environment variables, or can not solve the problem;

About Exception 3 This must be the JAMVM itself bug, unless the single-step debugging, otherwise may not be able to locate the problem, and even if the location, also absolutely cannot solve.

At the time of helpless, suddenly search for an international friend post, the post on my success played a decisive role, really situations, Vista!!! Thanks to the author of the sticker! URLs such as the following:

Http://www.webos-internals.org/wiki/Building_JamVM_and_GNU_Classpath_and_Jikes_ (For_java_support_in_webos) _ With_scratchbox2

In detail, this article refers to a very critical place, that is, when you are in the JAMVM, you need to enable the Libffi module, otherwise it will cause a paragraph error!

I follow the steps of the article, step by step down, and finally get the results I want! This article should use the scene is arm, and can take GUI,GTK and other applications, and my application scenario is relatively simple, that is, in the x86 below the application without GUI, so my compilation and he has some differences, detailed process such as the following:

1. Classpath related Operations

$ 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

Note: The default installation path for Classpath is/usr/local/classpath

2. JAMVM related Operations

$ 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. Verify JAMVM

1> known source ~/work/free/jamvm-1.5.4/java/helloworld.java:

public class HelloWorld {

public static void Main (string[] args) {

System.out.println ("Hello world!");

}

}

2> Compiling Javac Helloworld.java

Production Helloworld.class

3> run JAMVM HelloWorld print results:

helloworld!

At this point we are looking at classpath, Ld_library_path, found:

[Email protected]:~ $echo $CLASSPATH

[Email protected]:~ $echo $LD _library_path

:/usr/local/lib

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

[Email PROTECTED]:~/WORK/FREE/JAMVM-1.5.4/JAVA$JAMVM HelloWorld

helloworld!

Can see, classpath and Ld_library_path do not need to be set to say before, jamvm–version show those paths!!!

Finally, I hope this article can help the brothers who have encountered the same problem!

Ubuntu12.04 under jamvm1.5.4+classpath-0.98 successful execution Helloworld.class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.