Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the compilation process of KVM in J2ME

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how the KVM compilation process in J2ME is, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Here is a brief introduction to the process of compiling KVM under Windows. KVM does not use many optimization techniques in HotSpot JVM, and the code is very simple, which is helpful for us to understand the execution process of JAVA program. Although executing JAVA programs in KVM may not be quite the same as JVM, which is popular on PC today, the general principle is similar.

J2ME KVM

Compile KVM

KVM can be said to be a smaller and more primitive version of JVM. KVM is generally placed in embedded devices, such as mobile phones and other terminals with limited resources. KVM does not use many optimization techniques in HotSpot JVM, and the code is very simple, which is helpful for us to understand the execution process of JAVA program. Although executing JAVA programs in KVM may not be quite the same as JVM, which is popular on PC today, the general principle is similar.

Here is my process of compiling KVM in Windows.

1. Download the KVM source code

Http://www.sun.com/software/communitysource/j2me/cldc/download.xml

There are now two versions of cldc1.1 and cldc1.04. There's not much difference. I chose version 1.1 of the KVM source code.

two。 Download Cygwin

Although the KVM provided by Sun has a project compiled under VC6, the whole compilation process still requires the participation of Cygwin. Cygwin provides many programs such as make,gcc,grep,find under Linux, which are used in many makefile in KVM. Since it is under Windows, we can only download cygwin.

When installing cygwin, remember to install common tools such as gcc compiler and make,grep,find. In fact, you can also download Dev-Cpp this tool, which has cygwin's gcc,make but does not have grep,find these shell programs. So you should still download a cygwin. The cygwin version doesn't matter, even very old ones are fine. But cygwin is big.

Http://www.cygwin.org

3. Install JDK

There is no need for me to say much about this process, I installed JBuilder2005 directly.

4. Make compilation

After downloading the j2me_cldc, unzip it. Enter the j2me_cldc\ build\ win32 directory. There is a makefile file inside, which is the compiled file under the win32 environment.

The whole process needs to be done at a command prompt in windows, and PATH needs to be set up. Enter at the command prompt

PATH=D:\ CYGWIN\ BIN;D:\ Borland\ JBuilder2005\ jdk1.4\ bin;%PATH%

Then type make directly, and you can proceed with the entire compilation process. The whole compilation process should be smooth.

It is possible that the "* .java cannot be found" error is due to a conflict between a find.exe in Windows's command and the find.exe in cygwin\ bin, so cygwin\ bin should be put first.

5. Compile KVM under VC6

There is a dsw project file for VC6 under j2me_cldc\ kvm\ VmWin\ build, but you must go through the make compilation above before you can open the VC6 project file for compilation. Because the two files nativeFunctionTableWin.c and ROMjavaWin.c needed for the compilation of the entire KVM are generated after compiling and executing tools\ jcc, there will be no two files without compiling and executing tools\ jcc.

Jcc is to convert the bytecodes of Java core class files into a bunch of C language arrays, and then let KVM compile to include them. The bytecodes of these core class files is placed in the above two files. The advantage of this is that when KVM executes, you don't have to look for the core class file and load it.

6. Test and run the self-compiled KVM

If the compilation is successful, a VmWin.exe or kvm.exe file will be generated. You can test and write a helloworld.java, you do not need preverifier, you can directly run your helloworld.class.

SUN is already provided with a native function of putchar in the KVM of j2me cldc. You can add and modify the native function of Java according to your preferences. The whole KVM.exe has more than 200K, but the code may only be 80K, and the rest is Java's CLDC core class.

After reading the above, do you have any further understanding of the KVM compilation process in J2ME? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report