mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
When the runtime is ['assumed'](11b5c4ce67/cli/init.go (L182-L188)) (i.e. not explicitly set to 'java'), the [pom.xml isn't created(85ae711447/cli/langs/java.go (L38-L45)) and [init fail](85ae711447/cli/langs/java.go (L99-L101)).
1.2 KiB
1.2 KiB
Oracle Functions: Java
This example will show you how to test and deploy Java code to Oracle Functions. It will also demonstrate passing data in through stdin.
First, run the following commands:
# Initialize your function creating a func.yaml file
fn init <DOCKERHUB_USERNAME>/hello-java --runtime java
# Test your function. This will run inside a container exactly how it will on the server
fn run
# Now try with an input
echo "Michael FassBender" | fn run
# Deploy your functions to the Oracle Functions server (default localhost:8080)
# This will create a route to your function as well
fn deploy myapp
Now call your function:
curl http://localhost:8080/r/myapp/hello-java
Or call from a browser: http://localhost:8080/r/myapp/hello-java
That's it!
In Review
-
We passed in data through stdin
echo "Michael FassBender" | fn run -
We received our function input through stdin
String name = bufferedReader.readLine(); -
We wrote our output to stdout
System.out.println("Hello, " + name + "!");