Pablo Torrecilla Pablo Torrecilla - 1 year ago 139
Java Question

AWS Lambda: it is possible to use Oracle Java SDK?

I would like to use Amazon Lambda to run a component. However, this component has dependencies with some packages which seem to be only available in the Oracle's SDK.

I have read that AWS Lambda functions run on Linux Amazon AMI (which are Open SDK based). Actually, some time ago I tried to run my project on an EC2 instance and faced the same problem, so I switched to a standard Ubuntu 14.04 and I installed the Oracle Java 8 SDK.

Do you have any ideas?

Edit: the problem I'm finding is:

[2016-11-21T23:58:02.100] java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager
[2016-11-21T23:58:02.100] java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager
[2016-11-21T23:58:02.100] at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(

I think that class is only available in the Oracle's Java SDK.

Answer Source

If you check Lambda Execution Environment and Available Libraries, then you will get

If you are using any native binaries in your code, make sure they are compiled in this environment. Note that only 64-bit binaries are supported on AWS Lambda.

AWS Lambda supports the following runtime versions:

  1. Node.js – v0.10.36, v4.3.2 (recommended)
  2. Java – Java 8
  3. Python – Python 2.7

Q: What is the JVM environment Lambda uses for execution of my function?

Ans: Lambda provides the Amazon Linux build of openjdk 1.8.

Q: How do I compile my AWS Lambda function Java code?

You can use standard tools like Maven or Gradle to compile your Lambda function. Your build process should mimic the same build process you would use to compile any Java code that depends on the AWS SDK. Run your Java compiler tool on your source files and include the AWS SDK 1.9 or later with transitive dependencies on your classpath. For more details, see aws documentation.

You can also check: AWS Lambda: How It Works


If you check the github for jbrowserdriver, the pre-requisite are given


Java 8 with JavaFX:

  • Ubuntu Xenial 16.04 LTS, Debian 8 Jessie (Backports), Debian 9 Stretch:

    sudo apt-get install openjdk-8-jre openjfx
  • Ubuntu Trusty 14.04 LTS:

    sudo add-apt-repository ppa:webupd8team/java && sudo apt-get update && sudo apt-get install oracle-java8-installer libgtk2.0 libxtst6 libxslt1.1 fonts-freefont-ttf libasound2 && sudo update-alternatives --config java
  • Mac, Windows, Linux:

    install Oracle Java 8 (note: choose either the JRE or JDK but not the "Server JRE" since it doesn't include JavaFX)

Resource Link:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download