Files
fn-serverless/examples/tutorial/hello/java
2017-09-07 15:53:28 -07:00
..
2017-06-01 02:19:37 -07:00
2017-06-01 02:19:37 -07:00
2017-09-07 15:53:28 -07:00

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 --name 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 --app 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

  1. We passed in data through stdin

    echo "Michael FassBender" | fn run
    
  2. We received our function input through stdin

    String name = bufferedReader.readLine();
    
  3. We wrote our output to stdout

    System.out.println("Hello, " + name + "!");
    

Next Up

Tutorial 2: Input Parameters