KVM compilation process in the j2-kvm tutorial

Source: Internet
Author: User

Here we will briefly introduce the process of compiling KVM in Windows. KVM does not use many optimization technologies in the HotSpot JVM, and the code is very simple, which helps us understand the execution process of JAVA programs. Although the execution of JAVA programs in KVM may be different from the popular JVM on PC, the general principle is similar.

J2-kvm tutorial

Compile KVM

KVM is a relatively small and primitive version in JVM. KVM is generally placed on embedded devices, such as mobile phones and other terminals with limited resources. KVM does not use many optimization technologies in the HotSpot JVM, and the code is very simple, which helps us understand the JAVA program execution process. Although the execution of JAVA programs in KVM may be different from the popular JVM on PC, the general principle is similar.
The following describes how to compile KVM in Windows.

1. Download KVM source code

Http://www.sun.com/software/communitysource/j2me/cldc/download.xml
Currently, two versions are available: cldc1.1 and cldc1.04. The difference is not great. I chose the KVM source code version 1.1.

2. Download Cygwin

Although the KVM provided by Sun has a project compiled under VC6, part of the compilation process still requires Cygwin. Cygwin provides many programs in Linux such as make, gcc, grep, and find. These programs are used in many makefiles in KVM. In Windows, only cygwin is downloaded.
When installing cygwin, remember to install common tools such as gcc compiler, make, grep, and find. In fact, you can also download the Dev-Cpp tool, which contains gcc and make of cygwin but does not have grep and find these shell programs. So we should download a cygwin. It doesn't matter if cygwin is a very old version. But cygwin is huge.
Http://www.cygwin.org

3. Install JDK

I don't need to talk about this process. I just installed JBuilder2005 directly.

4. make Compilation

Download j2me_cldc and decompress it. Go to the j2me_cldc \ build \ win32 Directory. There is a makefile file, which is the compilation file in the win32 environment.
The entire process needs to be completed at the windows command prompt, and PATH needs to be set. Enter
PATH = D: \ CYGWIN \ BIN; D: \ Borland \ JBuilder2005 \ jdk1.4 \ bin; % PATH %
Then, you can directly input make to complete the compilation process. The entire compilation process should be smooth.
The error "*. java cannot be found" may occur. In most cases, the find.exe conflicts with the find.exe file in cygwin \ bin. cygwin \ bin should be placed in front.

5. Compile KVM under VC6

There is a dsw project file of VC6 under j2me_cldc \ kvm \ VmWin \ build. However, you must compile the file by making the above before opening the VC6 project file for compilation. Two nativeFunctionTableWin files are required for KVM compilation. c and ROMjavaWin. c is generated after compilation and execution of tools \ jcc. Without compilation and execution of tools \ jcc, there will be no such two files.

Jcc converts bytecodes of the Java core class file into a heap of C language arrays and then includes it during KVM compilation. The bytecodes of these core classes are placed in the above two files. The advantage of this is that you do not need to find the core class file during KVM execution and then load it.

6. Test and run the self-compiled KVM

If the compilation is successful, the vmwin.exe‑kvm.exe file will be generated. You can test to write helloworld. java and run your helloworld. class directly without preverifier.
SUN has provided a putchar native function in the kvm of the j2-cldc. You can add and modify the native function of Java based on your preferences. The entire kvm.exe has more than 200 kb, but the code may only have more than 80 KB. Others are the core CLDC class of Java.

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.