-
Notifications
You must be signed in to change notification settings - Fork 0
How to Develop Java Code for Lambda
First things first, you will need Maven. This is a tool that will allow you to build all of your code and it's dependencies together into a .jar file.
- Here is a link to get that downloaded.
- Here is a link to get that setup (i.e. path vars and whatnot need to be set properly).
The next few steps I got from this link.
Start by creating a completely empty directory where you want your project created. Open a command prompt and go to this directory and run this command:
mvn archetype:generate -DgroupId=ms3_testing_packaging -DartifactId=ms3_testing_project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Now cd into the directory that gets created create a file called pom.xml
Copy past the content of the wiki page 'pom.xml' into the just created file.
You should then run 'nvm clean install' and you should get a success message.
- If you get an error here about not having a jdk defined, you'll need to make sure to set up your JAVA_HOME environment variable to point to the appropriate directory. Remember to use the java 1.8 jdk as that's what is supported on lambda.
If prompted by your ide, sync maven changes. If changes don't appear to be taking effect, you may need to invalidate your cache and restart your ide.
When you go to develop any code, you must put it inside of the 'src/main/java/' directory or else the .jar file will not work.
Then, once you've created a lambda handler, use 'nvm clean package' to create the elusive .jar file.
Go to the lambda console and create your function, upload your .jar file which is in a sub directory of your project's root called 'target'. Make sure that the Handler is set to path.from.the.java.dir.ClassName::functionHandlerName