HELLO WORLD | SHARE PAGE |
CREATING A HELLO WORLD PROGRAM
After having downloaded and installed
Airship, run
airship init HelloWorld
and you should see this output:
$ airship init HelloWorld
This utility will walk you through creating a flat.json file. It
only covers the most common items, and tries to guess sensible
defaults.
Use \`airship add <pkg>\` afterwards to install a package and save
it as a dependency in the flat.json file.
Press ^C at any time to quit.
Package name (default: HelloWorld):
Initialize package in folder: "C:/Users/home/HelloWorld"? (Y/n): y
Package version (default: 0.1.0):
Package description: Flat Hello World program
Package author: Your Name
Package license (default: ISC):
Default compilation target (default: es6):
Main class (e.g.: example/ClassName) [optional - press enter to skip]: HelloWorld
Create a testing suite (HelloWorld_TestSuite)? (Y/n): y
Create a testing pipeline? (Y/n): y
Pipeline file (default: .github/workflows/test.yml):
Pipeline file created at "C:/Users/home/HelloWorld/.github/workflows/test.yml"
Once the initialization is finished, you should see a file with these contents at
HelloWorld/src/HelloWorld.flat
:
class {
public static main(String[] args) {
}
}
Now you can add a console logging statement to the main function like this:
class {
public static main(String[] args) {
Console.writeLine("Hello, world!")
}
}
Now you can install the HelloWorld program:
airship install
You should see a new js file generated at HelloWorld/dist/index.js
You can now run the HelloWorld program:
node dist/index.js
And you should see this logged out into to the console:
Hello, world!