mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Remove java tutorial, link to FDK (#504)
This commit is contained in:
committed by
Travis Reeder
parent
fe82fc724c
commit
8aa2c8958f
@@ -1,13 +0,0 @@
|
|||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class Func {
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
|
|
||||||
|
|
||||||
String name = bufferedReader.readLine();
|
|
||||||
name = (name == null) ? "world" : name;
|
|
||||||
|
|
||||||
System.out.println("Hello, " + name + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,51 +1,3 @@
|
|||||||
# Fn: Java
|
# Fn: Java
|
||||||
This example will show you how to test and deploy Java code to Fn. It will also demonstrate passing data in through stdin.
|
|
||||||
|
|
||||||
### First, run the following commands:
|
To learn how to build Java functions check out the [Fn Java FDK](https://github.com/fnproject/fdk-java)
|
||||||
|
|
||||||
```sh
|
|
||||||
# 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 Fn server (default localhost:8080)
|
|
||||||
# This will create a route to your function as well
|
|
||||||
fn deploy --app myapp
|
|
||||||
```
|
|
||||||
|
|
||||||
### Now call your function:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
curl http://localhost:8080/r/myapp/hello-java
|
|
||||||
```
|
|
||||||
|
|
||||||
Or call from a browser: [http://localhost:8080/r/myapp/hello-java](http://localhost:8080/r/myapp/hello-java)
|
|
||||||
|
|
||||||
That's it!
|
|
||||||
|
|
||||||
|
|
||||||
# In Review
|
|
||||||
|
|
||||||
1. We passed in data through stdin
|
|
||||||
```sh
|
|
||||||
echo "Michael FassBender" | fn run
|
|
||||||
```
|
|
||||||
|
|
||||||
2. We received our function input through **stdin**
|
|
||||||
```go
|
|
||||||
String name = bufferedReader.readLine();
|
|
||||||
```
|
|
||||||
|
|
||||||
3. We wrote our output to **stdout**
|
|
||||||
```go
|
|
||||||
System.out.println("Hello, " + name + "!");
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
# Next Up
|
|
||||||
## [Part 2: Input Parameters](../../params)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user