我有一些java文件,我想在linux cmd模式下運行它們。在那些java文件中,我使用了aws java sdk,所以我需要爲aws java sdk設置類路徑。下面是我做的:如何在linux cmd中導出AWS SDK(嘗試在linux中編譯java)
export CLASSPATH=/home/ubuntu/loadbalancer/aws-java-sdk-1.10.20/lib/aws-
java-sdk-flow-build-tools-1.10.20.jar:/home/ubuntu/loadbalancer/aws-java-
sdk-1.10.20/lib/aws-java-sdk-1.10.23-sources.jar:/home/ubuntu
/loadbalancer/aws-java-sdk-1.10.20/lib/aws-java-sdk-1.10.20.jar:
/home/ubuntu/loadbalancer/aws-java-sdk-1.10.20/lib/aws-java-sdk-1.10.20-
javadoc.jar:/home/ubuntu/loadbalancer
echo $CLASSPATH /home/ubuntu/loadbalancer/aws-java-sdk-1.10.20/lib/aws-
java-sdk-flow-build-tools-1.10.20.jar:/home/ubuntu/loadbalancer/aws-java-
sdk-1.10.20/lib/aws-java-sdk-1.10.23-sources.jar:/home/ubuntu
/loadbalancer/aws-java-sdk-1.10.20/lib/aws-java-sdk-1.10.20.jar:
/home/ubuntu/loadbalancer/aws-java-sdk-1.10.20/lib/aws-java-sdk-1.10.20-
javadoc.jar:/home/ubuntu/loadbalancer
當我做javac *.java
我得到這個堆棧跟蹤
javac *.java
LoadBalancer.java:15: package com.amazonaws.auth does not exist
import com.amazonaws.auth.BasicAWSCredentials;
^
LoadBalancer.java:16: package com.amazonaws.services.ec2 does not exist
import com.amazonaws.services.ec2.AmazonEC2Client;
^
LoadBalancer.java:17: package com.amazonaws.services.ec2.model does not exist
import com.amazonaws.services.ec2.model.CreateTagsRequest;
任何人都可以幫助嗎?
感謝您的回覆。我發現我的問題,我沒有將所有的jar文件導入到classpath中。 jar文件和路徑的區別很好! –