# Feasibility of using Julia to create a DLL connected to Java

**URL:** <https://discourse.julialang.org/t/feasibility-of-using-julia-to-create-a-dll-connected-to-java/114056>\
**Category:** New to Julia\
**Created:** [May 9, 2024, 1:51pm UTC](https://discourse.julialang.org/t/feasibility-of-using-julia-to-create-a-dll-connected-to-java/114056 "2024-05-09T13:51:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [May 9, 2024, 4:04pm UTC](https://discourse.julialang.org/t/feasibility-of-using-julia-to-create-a-dll-connected-to-java/114056/4 "2024-05-09T16:04:07Z")

</div>

Compiling Julia is possible, and you end with a DLL, it’s not going to be small, but I question why you need that, and I think you will not get just one DLL with PackageCompiler.jl. Also it you think compiling to DLL or anything is needed for speed then that’s not true basically, and since this is a physics engine, it seem like soft-realtime, and that has special requirements, I’ll address lalter.

> [@TravisB](#):
>
> 1. Is integrating Julia into mixed-language projects (e.g. Java) feasible?

Certainly. Look at e.g. the PythonCall.jl project. It’s by-directional, i.e. ses it’s [py]juliacall.

But that and RCall.jl and such a project to call in the other direction, to call Julia, are not made for compiling the Julia code first to a DLL. Though I do not think it’s ruled out using those projects if you’ve already done that.

I would first as a prototype just try to use Julia from Java without thinking of a DLL, to see if it’s fast enough, and you like the language. Julia should be, can be, as fast as anything out there if you do things right.

See the discussion here/first post at least and my answer, in short, it’s not just for statistics or just from e.g. Stata:

> [@Julia as a universal platform for statistical software development](https://discourse.julialang.org/t/julia-as-a-universal-platform-for-statistical-software-development/113017/12):
>
> It’s a great vision, that I share (for selfish reasons, helps add or improve Julia packages). I would say there’s nothing about the vision limiting it to stats… so you could amend the title, or keep as you wish. Thanks for adding Stata to the list. Even if only viable for it or other language, e.g. Python, then worthwhile. I know you can call easily to Python, I did (then with PyCall; also to MATLAB and Octave), and from Python, and believe it’s very solid with PythonCall, hopefully as good for…

I’ve not tried this, but it at least exists:

> **[GitHub - jbytecode/juliacaller: A library for calling Julia from Java](https://github.com/jbytecode/juliacaller)**
>
> A library for calling Julia from Java. Contribute to jbytecode/juliacaller development by creating an account on GitHub.

FYI: This is an older package:

> **[GitHub - JuliaInterop/JavaCall.jl: Call Java from Julia](https://github.com/JuliaInterop/JavaCall.jl)**
>
> Call Java from Julia. Contribute to JuliaInterop/JavaCall.jl development by creating an account on GitHub.

> [@Running Julia from JAVA? What is crazier?](https://discourse.julialang.org/t/running-julia-from-java-what-is-crazier/31662):
>
> Hey everyone, I’m exploring UI tools and integrating them with Julia. As part of this exercise I ended up making a nice UI in JAVAFX, now I need to hook it into Julia… So there’s two ways to go about this from what I understand(if there are others please suggest!). have a server where JAVA sends instructions to be understood by Julia (zmq, webio, whatever). have JAVA natively call Julia code and use some kind of wrapper ([https://github.com/rssdev10/julia4j](https://github.com/rssdev10/julia4j) - probably outdated by now) and inte…

You can call C from Java, and from C the C API, i.e. that way, or with projects helping, that in effect do this for you.

If it helps you and you can call C++ from Java (I’m sure you can) then it may be better to call Julia from it with, a project I’ve great confidence in/well documented:

> **[GitHub - Clemapfel/jluna: Julia Wrapper for C++ with Focus on Safety,...](https://github.com/Clemapfel/jluna)**
>
> Julia Wrapper for C++ with Focus on Safety, Elegance, and Ease of Use - Clemapfel/jluna

The C API to Julia handles only basic types, one reason I point to the above C++ project, it relates to:

> [@TravisB](#):
>
> a DLL which can pass custom data types to/from a front end

It’s also an option to call Python, and with the project above to Julia, in case it’s more mature then the other projects above.

The problem with mixing Java, a GC-language with another GC-language, such as Julia or Python, is that which GC should work (or both?). Java has good real-time GC available, Julia does not, so for a soft (or hard) real-time project you want to eliminate GC activity, meaning heap-allocations from the, or if soft-realtime, at least limit it. Though you may tolerate the Julia GC activity. In Julia instead of having a very good garbage collector for real-time, you rather want to eliminate the need for GC, and that’s a good approach, e.g. for robotics, but then you have to be careful. One project might help, it’s a bit limited yet, e.g. doesn’t support the GC, but for you it might be a plus: StaticCompiler.jl

---

_[View the full topic](https://discourse.julialang.org/t/feasibility-of-using-julia-to-create-a-dll-connected-to-java/114056)._
