Code Monkey home page Code Monkey logo

djvm's Introduction

djvm

Gitter

Copyright 2015 James Mahler
Licensed under the terms of the MIT license - See LICENSE

Allows for access to Java JVM from D. Provide D'esk interfaces as the C interaction into JNI is messy to say the least. This is a slow work in progress.

Motivation

The main motivation behind this is to provide simple access to things that run on the JVM. Two possibilities that come up immediately are JDBC and Hadoop. Using JNI from C/C++ to embed a JVM into an application is one of the ways to provide database access. To utilize technologies like HSQLDB, I believe it is currently the only way.

Getting Started

Requirements:

  • Java VM (if using package manager, make sure to install -dev packages)
  • dmd
  • LD_LIBRARY_PATH pointing to jvm install (/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server for example)

Compiling (For now I just do this in the source/djvm directory):

  • dub

Example

Here is an example usage of the D api:

DJvm djvm = new DJvm("");
scope(exit) {
	djvm.destroyJvm();
}

JClass systemCls = djvm.findClass("java.lang.System");
JClass printCls = djvm.findClass("java.io.PrintStream");

JStaticField field = systemCls.getStaticField("out", JniType!("java.io.PrintStream"));
jobject obj = field.getObject();

JMethod method = printCls.getMethod("println", JniSig!(["int"], "void"));
method.callVoid(obj, 100);

Work

Work is now being tracked through issues.

djvm's People

Contributors

gitter-badger avatar jamesmahler avatar rikkimax avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.