Java идеальна для системного программирования

Копия моего поста http://community.livejournal.com/ru_java/750688.html

Смотрите на мир незашоренными глазами:
Java идеальна для написания системных утилит.
Java действительно прекрасный выбор для системного программирования.

Главное понять, что некоторые различия ОС не обработаны заботливым изготовителем JRE и не поданы на блюдечке, а их потребуется обрабатывать вручную, точно также как это делают в Delphi/C++.

Т.е. отсуствующие в JRE методы реализуете вызовами к ОС (проверяя что за ОС).
  • Стандартный способ JNI: слишком много писать - это как писать в машинном коде.
Как надо:
  • Если надо работать с процедурным API (ex: WinAPI) то есть:
  1. https://jna.dev.java.net/
  2. http://www.jinvoke.com/
  3. http://fivedots.coe.psu.ac.th/~ad/winJava/ (несколько глав книги Windows Programming Using Java - они используют JInvoke, но думаю будет полезно и для JNA и для Linux ;-)
  • Если надо работать с ООП API (ex: COM) то есть:
  1. https://com4j.dev.java.net/
  2. http://jacob-project.sf.net

JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.

JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.

The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.

While some attention is paid to performance, correctness and ease of use take priority.

J/Invoke - easy Java native interoperability

J/Invoke enables Java developers to easily invoke native methods (such as the Win32 API or C-based Windows DLLs and Unix dynamic libraries) with pure Java code.

Unlike error-prone JNI programming that is hard to use and deploy, J/Invoke lets you access native libraries by simply declaring native methods, and calling them from pure Java.

Java programmers can save time, avoid errors and increase productivity by using J/Invoke to

* Call native libraries from pure Java, without using JNI
* Use OS features and APIs (like the Win32 API), not available through Java
* Integrate Java applications with native libraries (Windows DLLs, Mac OS X, Linux and Solaris dynamic libraries)
* Provide Java API for native DLLs or other non-Java libraries

Do all this and more with pure, simple Java - no need to mess with C/C++ programming with error-prone and hard to use JNI, deploying intermediate DLLs, and dealing with parameter conversions between Java and native types.

Q: Хм.. Для меня системное программирование — это программирование систем, возможно операционных!

1) http://www.jnode.org/
Java New Operating System Design Effort.
JNode is a simple to use & install Java operating system for personal use.
It runs on modern devices.
Any java application will run on it, fast & secure!
(open source, LGPL)

2. http://en.wikipedia.org/wiki/JavaOS

3. http://www-jpc.physics.ox.ac.uk/
JPC is an x86 PC emulator written entirely in Java. Open Source!

Researchers at Oxford have built an x86 emulator that runs purely on Java, making it ideal for security researchers who want to analyze and archive viruses, host honeypots and defend themselves against buggy or malicious software without hosing their machines. The JPC also emulates a host of other environments, giving technophiles the ability to play Asteroids and other software that's sat on shelves for years collecting dust.

What's more, JPC will run on any device with a Java virtual machine, so cell phones, set-top boxes and RISC systems are all fair game, according to researchers in the university's physics department, where the project was developed.

"Some might see JPC as part of a nefarious plot by mad scientists who want to harness every last CPU in the world for their research - but we prefer to see JPC as Java-hardened protection against their buggy programs," they say. JPC's Java-based architecture gives it cross-platform capability, the security of running code in the Java sandbox and the flexibility of configuring virtualization platforms and software libraries.

The researchers boast its x86 emulation, at 10 per cent native speed, puts it among the fastest x86 emulators. (Note: an earlier version of this story incorrectly reported JPC emulated other environments.)

Весь креатив в Москве...

Дорога на Абаву

Вероятно с Белорусского вокзала...