Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

07-compiler-usage, added --jvm #466

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/07-compiler-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The second question usually comes down to providing an argument specifying the d
* `--cpp <directory>` Generate [C++](target-cpp) source code in specified directory and compiles it using native C++ compiler.
* `--cs <directory>` Generate [C#](target-cs) source code in specified directory.
* `--java <directory>` 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 <file_name.jar>` Generate [JVM bytecode](target-jvm) as a jar file.
* `--python <file_name.py>` Generate [Python](target-python) source code in the specified file.
* `--lua <file_name.lua>` Generate [Lua](target-lua) source code in the specified file.
* `--hl <file_name.hl>` Generate [HashLink](target-hl) byte code in specified file.
Expand Down
46 changes: 46 additions & 0 deletions content/12-target-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,52 @@ java -jar bin/Main.jar



<!--label:target-jvm-->
### JVM

<!--subtoc-->

<!--label:target-jvm-getting-started-->
#### 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/).
uvtc marked this conversation as resolved.
Show resolved Hide resolved

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.
uvtc marked this conversation as resolved.
Show resolved Hide resolved

```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/)





<!--label:target-cs-->
### C#
Expand Down