| 1 |
--- |
| 2 |
title: Java |
| 3 |
short-description: Compiling Java programs |
| 4 |
... |
| 5 |
|
| 6 |
# Compiling Java applications |
| 7 |
|
| 8 |
Meson has experimental support for compiling Java programs. The basic |
| 9 |
syntax consists of only one function and would be used like this: |
| 10 |
|
| 11 |
```meson |
| 12 |
project('javaprog', 'java') |
| 13 |
|
| 14 |
myjar = jar('mything', 'com/example/Prog.java', |
| 15 |
main_class : 'com.example.Prog') |
| 16 |
|
| 17 |
test('javatest', myjar) |
| 18 |
``` |
| 19 |
|
| 20 |
However note that Meson places limitations on how you lay out your code. |
| 21 |
|
| 22 |
* all Java files for a jar must be under the subdirectory the jar definition is in |
| 23 |
* all Java files must be in paths specified by their package, e.g. a class called `com.example.Something` must be in a Java file situated at `com/example/Something.java`. |
| 24 |
* Meson only deals with jar files, you cannot poke individual class files (unless you do so manually) |