Designing a Cross-platform Java UI with native performance: using JNI to access the Slik skin interface

Source: Internet
Author: User
Tags relative

Description: Can you write Java code that compiles across multiple platforms while still executing as fast as native code? This is a challenge for Java developers, especially for applications with complex UIs. In this article, developer Vladimir Silva suggested an interesting solution to the problem. You will learn how to use JNI to access Slik, a cross-platform C API that provides native performance on both Windows and UNIX.

The Java language dominates middle-tier development relative to traditional languages such as C and C + +. The reason that the Java language is universally accepted in the development community is its object-oriented design, platform-independent nature, and a rich support API. However, it has failed to manage the desktop as a real development platform-perhaps for the same reason that it dominates the middle tier. Platform independence means that performance can be significantly reduced relative to native C and C + + applications.

The purpose of this article is to demonstrate the binding of Java with a simple skin interface (simplistic Skin Interface, also known as Slik) (see Resources for more details). Slik is a C API that can be used to build Cross-platform GUIs. By using the Java Native Interface (Java Native Interface, JNI), you can bind Java code to Slik to design a Cross-platform user interface that executes like C and C + +.

Java language and C: Dynamic duet

Java technical support is tied to multiple languages, including C + +, Fortran, and so on. This exceptional feature provides developers with unparalleled flexibility to write APIs that require some operating system-related functionality.

To demonstrate Slik's advanced user interface features, I'll show you how to build a UI without a rectangular window (also known as skin or skin-facing windows), which requires low-level APIs that the Java language does not currently provide. Java provides the means to access any operating system-related services using JNI. On the local side, C is the best language choice, and the modified version of the Slik I will use provides the multi-platform C API that implements this article's objectives.

A detailed introduction to JNI is beyond the scope of this article, please refer to the Resources section below for more information on this topic. One important thing to keep in mind is that Slik is written in C, and you need JNI to access it from code written in the Java language.

Slik overview

Slik is a C API for building an advanced user interface based on WINAMP-style skin. Examples of such interfaces include audio and video players such as the popular XMMS (X-multimedia system, X-Media systems) and Xine CD/DVD players used for UNIX-like systems. The basics of using this API as a GUI have many benefits:

Slik includes a set of enhanced widgets, such as buttons, menus, windows, lists, and high-resolution images not provided by the current Window toolkit.

This API can be used for multiplatform design because its core libraries can be compiled simultaneously under Microsoft Windows and Unix-like systems.

Slik can be implemented as a Windows DLL or UNIX shared object library, which means it can be reused across multiple applications and is easy to maintain.

The Slik software is provided by the Gqmpeg group under the GNU Public License (GNU Common LICENSE,GPL). The Slik version provided by the GQMPEG team is compiled only as an executable file on UNIX-like systems. I created a modified version that works at the same time on Win32 and UNIX systems; This version is provided in binary form along with the source code of this article (both Windows DLLs and Unix shared objects or so versions).

I also provided makefile for UNIX and Windows environments.

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.