Java without JVM

被刻印的时光 ゝ 提交于 2019-12-07 06:01:20

问题


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.


回答1:


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




回答2:


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 .




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/13555187/java-without-jvm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!