Java without JVM

2019-05-02 04:00发布

Just wondering if there are any Java implementations that work without a JVM. The reason I'm interested is, well, simply because I'm curious, and I was wondering if there were any "lightweight" Java implementations (without all the Sun libs attached).

I'm also interested in embedding Java in C++, but embedding the JVM in C++ seems rather ridiculous to me. I just want to exploit some of the Java language features in my C++ apps, but not exploit all the frivolous Java APIs.

EDIT:

I see from a lot of the answers I've gotten that I need to clarify...

I recently got in to developing node.js applications, which uses JavaScript. JavaScript in istelf is a language spec, it doesn't automatically come with the DOM, window.open, etc., although it did for a while. I'm wondering if there's something similar to Google's v8, except not for JavaScript, but for Java. In the end, I don't care if I can't write Hello World apps with it, I just want to be able to embed Java in a C++ application the way I can embed JavaScript in a C++ application with v8 or SpiderMonkey. If I could do that, then I could implement console output in C/C++ and then make that implementation callable from Java.

标签: java jvm embed
5条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-05-02 04:20

IMHO, You need to re-exampine what it is you really want.

Java runtime consists of two main components

  • The JVM to run the code
  • The standard libraries which come with it.

You suggest you want to use Java, but you don't really have anything left without these.

For example, you cannot even write a "hello world" program without the libraries as String is a class in the JDK.

查看更多
在下西门庆
3楼-- · 2019-05-02 04:34

There's GCJ (GNU Compiler for Java), but the project has been deprecated since OpenJDK was open sourced.

查看更多
Viruses.
4楼-- · 2019-05-02 04:38

Do you want the Java VM alone without the API(STandard Library) ?

The JRE is composed by the JVM (Virtual MAchine) and the Standard Library, I have doubt that you can find a java implementation without the JVM ... You could find a compiler that compile java source code into native code(take a look at GCJ), but not a Java implementation without the VM.

Take a look at this wikipedia page to see some alternative Java implementations .

查看更多
唯我独甜
5楼-- · 2019-05-02 04:42

there are light weight java processors designed for use in small devices for example JOP

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-05-02 04:42

As others have hinted, the "JVM" is the mechanism that knows how to load classes, interpret "bytecodes", and manage storage. It does not inherently include any of the java.lang... stuff, except that a few classes (String, Class, et al) are needed to represent classes and other basic data structures in the JVM.

As a result, Java without a JVM is just a bunch of meaningless bits.

There are (or were) compiled versions of Java that do/did not need the interpreter (though a reasonably compact interpreter is quite easy to build). A primitive class loader and some sort of storage management are still necessary, but class loading can be kept simple and for short-lived apps (or those that live with special restrictions) the storage manager need not do garbage collection.

As pstanton suggests, there are "lightweight" Java (or "Java-like") implementations that are suited for small devices.

查看更多
登录 后发表回答