From 8f3c6dcc5c682ebe425cf4fa72fcb514adbb999e Mon Sep 17 00:00:00 2001 From: John Gabriele Date: Thu, 16 Jul 2020 17:56:39 -0400 Subject: [PATCH 1/4] 07-compiler-usage, added `--jvm` I put it after `--java`, like in the output of `haxe --help`. --- content/07-compiler-usage.md | 1 + 1 file changed, 1 insertion(+) diff --git a/content/07-compiler-usage.md b/content/07-compiler-usage.md index d92269bb..28fa2a36 100644 --- a/content/07-compiler-usage.md +++ b/content/07-compiler-usage.md @@ -30,6 +30,7 @@ The second question usually comes down to providing an argument specifying the d * `--cpp ` Generate [C++](target-cpp) source code in specified directory and compiles it using native C++ compiler. * `--cs ` Generate [C#](target-cs) source code in specified directory. * `--java ` Generate [Java](target-java) source code in specified directory and compiles it using the Java Compiler. Add `-D jvm` to generate JVM byte code directly bypassing Java compilation step. +* `--jvm ` Generate [JVM bytecode](target-jvm) as a jar file. * `--python ` Generate [Python](target-python) source code in the specified file. * `--lua ` Generate [Lua](target-lua) source code in the specified file. * `--hl ` Generate [HashLink](target-hl) byte code in specified file. From f6d041b92452c936d2dc64c276ebb3b76100c334 Mon Sep 17 00:00:00 2001 From: John Gabriele Date: Thu, 16 Jul 2020 18:05:14 -0400 Subject: [PATCH 2/4] 12-target-details, added JVM target --- content/12-target-details.md | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/content/12-target-details.md b/content/12-target-details.md index f42a94cd..ed4123ff 100644 --- a/content/12-target-details.md +++ b/content/12-target-details.md @@ -1945,6 +1945,52 @@ java -jar bin/Main.jar + +### JVM + + + + +#### Getting started with Haxe/JVM + +To get started with Haxe/JVM, create a new folder and save this class as `Main.hx`. + +[code asset](assets/HelloWorld.hx) + +To compile Haxe to JVM bytecode we need two obvious prerequisites installed: + +* [hxjava haxelib](http://lib.haxe.org/p/hxjava). This is the support library for the Java backend of the Haxe compiler. +* [JRE - Java Runtime Environment](https://java.com/download/). + +Run the following from the command line: + +```hxml +haxe --jvm bin/Main.jar --main Main +``` + +Another possibility is to create and run (double-click) a file called `compile.hxml`. In this example the hxml-file should be in the same directory as the example class. + +```hxml +--jvm bin/Main.jar +--main Main +``` + +The compiler outputs in the given **bin**-folder, which contains the generated .jar file which prints the traced message when you execute it. + +To execute, run the following command: + +```sh +java -jar bin/Main.jar +``` + +##### More information + +* [Haxe/Java API docs](https://api.haxe.org/java/) +* [Java Platform Documentation](https://docs.oracle.com/javase/) + + + + ### C# From 7cd1598d0a96afea70ce4e789af45b3dbb76fd29 Mon Sep 17 00:00:00 2001 From: John Gabriele Date: Fri, 17 Jul 2020 13:57:38 -0400 Subject: [PATCH 3/4] 12-target-details.md, JVM, clarified prereqs Also changed link to JVM (OpenJDK), clarified note about running the jar file. --- content/12-target-details.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/content/12-target-details.md b/content/12-target-details.md index ed4123ff..fa022134 100644 --- a/content/12-target-details.md +++ b/content/12-target-details.md @@ -1957,32 +1957,36 @@ To get started with Haxe/JVM, create a new folder and save this class as `Main.h [code asset](assets/HelloWorld.hx) -To compile Haxe to JVM bytecode we need two obvious prerequisites installed: +To compile Haxe to JVM bytecode, you'll first need to install the [hxjava haxelib](http://lib.haxe.org/p/hxjava). This is the Haxe Java support library, including build scripts and support code. Then run the following from the command line: -* [hxjava haxelib](http://lib.haxe.org/p/hxjava). This is the support library for the Java backend of the Haxe compiler. -* [JRE - Java Runtime Environment](https://java.com/download/). - -Run the following from the command line: - -```hxml +```sh haxe --jvm bin/Main.jar --main Main ``` -Another possibility is to create and run (double-click) a file called `compile.hxml`. In this example the hxml-file should be in the same directory as the example class. +To save yourself some typing, you may create a `.hxml` file (say, `jvm.hxml`) in your project's top-level directory, containing: ```hxml --jvm bin/Main.jar --main Main ``` -The compiler outputs in the given **bin**-folder, which contains the generated .jar file which prints the traced message when you execute it. +and run it with the `haxe` command: -To execute, run the following command: +```sh +haxe jvm.hxml +``` + +to produce the bin/Main.jar file. + +To execute the jar file, you'll need to have a JRE (Java Runtime Environment) installed, such as [OpenJDK](https://openjdk.java.net/) or a commercially-supported JRE. Then run the jar file using the following command: ```sh java -jar bin/Main.jar ``` +Note that some operating systems may allow you to double-click a jar file to run it. + + ##### More information * [Haxe/Java API docs](https://api.haxe.org/java/) From be611175d4283270f32b92195359e4212b4de4fd Mon Sep 17 00:00:00 2001 From: John Gabriele Date: Fri, 17 Jul 2020 14:01:06 -0400 Subject: [PATCH 4/4] removed note about some OS's allowing double-click jar --- content/12-target-details.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/content/12-target-details.md b/content/12-target-details.md index fa022134..fa728f88 100644 --- a/content/12-target-details.md +++ b/content/12-target-details.md @@ -1984,8 +1984,6 @@ To execute the jar file, you'll need to have a JRE (Java Runtime Environment) in java -jar bin/Main.jar ``` -Note that some operating systems may allow you to double-click a jar file to run it. - ##### More information