Although Jetty is a program written in Java , It can be used across platforms, but it needs a Java virtual machine to start, and the Java virtual machine is not cross-platform. It is necessary to look for a Java virtual machine that can be used in a Linux system and takes up the smallest possible space. Since arm only provides up to 52M of space, we have to exclude our most commonly used sun company jre, because its installation directory reaches 134M, which greatly exceeds the available space, and the cutting work is not easy.
After searching the information, it is basically confirmed The following schemes:
/p>
1) CVM + jetty5
SUN’s J2ME is specially designed for mobile devices. It has been widely used in mobile communication devices and is very suitable for use in embedded systems. . CVM is a Java virtual machine with complete J2SE L3 VM support, but it is smaller than the standard J2SE VM. As a full-featured Java virtual machine, CVM supports almost all the advanced features of J2SE VM, including the lowest level of error handling and native language interfaces.
2) Android + i-jetty
I-jetty is a web container developed by Google based on jetty that runs on the Android platform, enabling mobile phones to build web services.
3) Jamvm + GNU classpath + jetty5
Jamvm is an open source java virtual machine written in C language, which uses GNU classpath as the java class library.
First use the first scheme, see me for the specific operation process Another article by, I just want to explain the results here. After testing the CVM of the arm platform, it is found that the output of the built-in HelloWorld and Test programs is normal, but java.lang.UnsatisfiedLinkError will appear when jetty is started. According to the error prompt, check that the class library is indeed missing a lot of classes. Later, the use of trimmed rt.jar still showed abnormalities. It seems that CVM is only suitable for small applications, and it is not suitable for relatively large network programs such as jetty.
The second solution was rejected without too much research. Our arm board is running linux and it is impossible to replace it with Android. If you want to use i-jetty, you have to install an Android emulator, but the emulator takes up a lot of space, so it didn’t take too long to try.
The third option is the one with the longest research time and the most likely implementation. Although there is linux on the arm board, the program cannot be compiled on it due to hardware limitations, so other hosts must be prepared to complete the compilation work, and then the files are copied to the arm board. At first I used the Redhat Linux virtual image that my colleague gave me, but no matter how I compiled the classpath, I couldn’t compile it. I have searched a lot of information about this on the Internet, and no one has successfully compiled jamvm + classpath under Redhat, but has succeeded under Ubuntu. So I installed a virtual image of the Ubuntu 8.04 server version in VMware (downloadable from the project server). After several days of compilation and debugging, I finally found a version combination that can be successfully compiled.
The compilation environment and operation process mainly explained below is based on the third scheme jamvm + GNU classpath.
Compilation environment and tools
Ubuntu 8.04 virtual mirror
The image on the project server has been installed with other tools required for compilation, such as gcc, zlib, gcj, ecj, etc. If you use other Ubuntu versions, you need to install them according to the prompts when compiling program of.
Arm cross compilation chain 4.3.2
The provided virtual image has been installed, no need to install again, it is used to compile c and c++ programs running on the arm platform.
GNU Classpath 0.93
Used by Jamvm The java class library needs to be cross-compiled.
Jamvm 1.5.1
An open source The java virtual machine needs to be cross-compiled.
Jetty 5.1.12
Written in Java The open source web container does not need to be cross-compiled.
Most of our work is Completed in the virtual machine, including compilation, packaging, testing, etc., although the results of running on the arm and the virtual machine may be different, but after my running test, I found that if it fails to run on the arm and makes a mistake, The same error occurs when running in a virtual machine, so I usually debug it in the virtual machine, and the program can run and then put it on the arm board, so the success rate is greater.
Working directory \home\kiki\work
Arm cross-compilation chain , GNU Classpath, jamvm and jetty5 source programs are all stored in the work directory, and the path of the arm cross-compilation chain needs to be specified in the environment variable.
Target directory\tmp
In order to be the same as the target directory of the arm platform, use the tmp folder as the target folder for compilation. Used to store the files compiled by GNU Classpath and jamvm. You need to specify the target path during configure.
Reposted from: http://www.xuehuile.com/blog/list_467ab95c0827437c8a94352b5d1b4976_1.html