jcompiler

Simple and efficient API to compile Java code at runtime (in-memory). Based on InMemoryCompiler.

Лицензия

Лицензия

Группа

Группа

eu.mihosoft.jcompiler
Идентификатор

Идентификатор

jcompiler
Последняя версия

Последняя версия

0.4
Дата

Дата

Тип

Тип

jar
Описание

Описание

jcompiler
Simple and efficient API to compile Java code at runtime (in-memory). Based on InMemoryCompiler.
Ссылка на сайт

Ссылка на сайт

https://github.com/miho/JCompiler
Система контроля версий

Система контроля версий

https://github.com/miho/JCompiler.git

Скачать jcompiler

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/eu.mihosoft.jcompiler/jcompiler/ -->
<dependency>
    <groupId>eu.mihosoft.jcompiler</groupId>
    <artifactId>jcompiler</artifactId>
    <version>0.4</version>
</dependency>
// https://jarcasting.com/artifacts/eu.mihosoft.jcompiler/jcompiler/
implementation 'eu.mihosoft.jcompiler:jcompiler:0.4'
// https://jarcasting.com/artifacts/eu.mihosoft.jcompiler/jcompiler/
implementation ("eu.mihosoft.jcompiler:jcompiler:0.4")
'eu.mihosoft.jcompiler:jcompiler:jar:0.4'
<dependency org="eu.mihosoft.jcompiler" name="jcompiler" rev="0.4">
  <artifact name="jcompiler" type="jar" />
</dependency>
@Grapes(
@Grab(group='eu.mihosoft.jcompiler', module='jcompiler', version='0.4')
)
libraryDependencies += "eu.mihosoft.jcompiler" % "jcompiler" % "0.4"
[eu.mihosoft.jcompiler/jcompiler "0.4"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.github.classgraph : classgraph jar 4.6.32

Модули Проекта

Данный проект не имеет модулей.

JCompiler

Download javadoc Java CI with Gradle

The purpose of this project is to provide a simple API for in-memory compilation of Java code. While the JDK provides a full-blown API for this, in many cases a much simpler API is sufficient.

This project is based on abandoned code by @trung and a reduced version of language utils from VRL.

Using JCompiler

Note: This project needs the full JDK as runtime-dependency to work properly (the JRE does not contain the JavaCompiler API).

Compiling Java classes is as simple as this:

// compile code
CompilationResult result = JCompiler.newInstance().
compile(
    "public class MyClass {\n"+
    "  public static String hello() {\n"+
    "    return \"hello\";\n"+
    "  }\n"+
    "}"
).checkNoErrors();
// load class and invoke static method
Class<?> myClass = result.loadClasses().get("MyClass");    
String msg = (String)myClass.getMethod("hello").invoke(null);          

How To Build The Project

1. Dependencies

  • JDK >= 8 (tested with JDK 11 and 13)
  • Internet Connection (other dependencies will be downloaded automatically)
  • Optional: IDE with Gradle support

2. Building

IDE

To build the project from an IDE do the following:

  • open the Gradle project
  • call the assemble Gradle task to build the project

Command Line

Building the project from the command line is also possible.

Navigate to the project folder and call the assemble Gradle task to build the project.

Bash (Linux/OS X/Cygwin/other Unix-like OS)
cd Path/To/JCompiler
./gradlew assemble
Windows (CMD)
cd Path\To\JCompiler
gradlew assemble

Версии библиотеки

Версия
0.4
0.3
0.2
0.1