AWS Lambda:可以使用 Oracle Java SDK 吗?
AWS Lambda: it is possible to use Oracle Java SDK?
我想使用 Amazon Lambda 来 运行 一个组件。但是,该组件依赖于某些包,这些包似乎只能在 Oracle 的 SDK 中使用。
我读到 AWS Lambda 在 Linux Amazon AMI(基于 Open SDK)上运行 运行。实际上,前段时间我尝试在 EC2 实例上 运行 我的项目并遇到同样的问题,所以我切换到标准 Ubuntu 14.04 并安装了 Oracle Java 8 SDK。
你有什么想法吗?
编辑:我发现的问题是:
[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(JBrowserDriverServer.java:74)
我认为 class 仅在 Oracle 的 Java SDK 中可用。
如果你勾选Lambda Execution Environment and Available Libraries,那么你会得到
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:
- Node.js – v0.10.36, v4.3.2 (recommended)
- Java – Java 8
- Python – Python 2.7
问:Lambda 用于执行我的函数的 JVM 环境是什么?
Ans: Lambda provides the Amazon Linux build of openjdk 1.8.
问:如何编译我的 AWS Lambda 函数 Java 代码?
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.
您还可以查看:AWS Lambda: How It Works
更新:
如果您勾选 github for jbrowserdriver,则已提供先决条件
先决条件
Java 8 与 JavaFX:
Ubuntu Xenial 16.04 LTS, Debian 8 Jessie (Backports), Debian 9
拉伸:
sudo apt-get install openjdk-8-jre openjfx
Ubuntu 可信 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(注意:选择 JRE 或 JDK 但不要选择 "Server JRE",因为它不包括 JavaFX)
资源Link:
我想使用 Amazon Lambda 来 运行 一个组件。但是,该组件依赖于某些包,这些包似乎只能在 Oracle 的 SDK 中使用。
我读到 AWS Lambda 在 Linux Amazon AMI(基于 Open SDK)上运行 运行。实际上,前段时间我尝试在 EC2 实例上 运行 我的项目并遇到同样的问题,所以我切换到标准 Ubuntu 14.04 并安装了 Oracle Java 8 SDK。
你有什么想法吗?
编辑:我发现的问题是:
[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(JBrowserDriverServer.java:74)
我认为 class 仅在 Oracle 的 Java SDK 中可用。
如果你勾选Lambda Execution Environment and Available Libraries,那么你会得到
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:
- Node.js – v0.10.36, v4.3.2 (recommended)
- Java – Java 8
- Python – Python 2.7
问:Lambda 用于执行我的函数的 JVM 环境是什么?
Ans: Lambda provides the Amazon Linux build of openjdk 1.8.
问:如何编译我的 AWS Lambda 函数 Java 代码?
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.
您还可以查看:AWS Lambda: How It Works
更新:
如果您勾选 github for jbrowserdriver,则已提供先决条件
先决条件
Java 8 与 JavaFX:
Ubuntu Xenial 16.04 LTS, Debian 8 Jessie (Backports), Debian 9 拉伸:
sudo apt-get install openjdk-8-jre openjfx
Ubuntu 可信 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(注意:选择 JRE 或 JDK 但不要选择 "Server JRE",因为它不包括 JavaFX)