Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java without JVM

Tags:

java

jvm

embed

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.

like image 403
Jrop Avatar asked Nov 25 '12 20:11

Jrop


People also ask

Does Java program run without the JDK?

The JDK is required to develop and run Java applets and applications. The JRE is used to run Java programs. It is required to run any Java programs.

What is JVM and why it is required?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation.


5 Answers

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 .

like image 132
aleroot Avatar answered Oct 17 '22 09:10

aleroot


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

like image 34
Lie Ryan Avatar answered Oct 17 '22 09:10

Lie Ryan


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

like image 45
pstanton Avatar answered Oct 17 '22 11:10

pstanton


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.

like image 34
Hot Licks Avatar answered Oct 17 '22 09:10

Hot Licks


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.

like image 1
Peter Lawrey Avatar answered Oct 17 '22 10:10

Peter Lawrey