I am trying to compile a .class
from my .java
source code, using a JAR I have downloaded locally to a download
directory in my project directory tree. I am using this JAR.
The .jar
file exists where I expect it to be:
$ file download/amazon-sqs-java-messaging-lib-2.1.1.jar
download/amazon-sqs-java-messaging-lib-2.1.1.jar: Zip archive data, at least v1.0 to extract
The .jar
file contains the class that javac
fails to find:
$ jar -tf download/amazon-sqs-java-messaging-lib-2.1.1.jar | grep SQSConnectionFactory.class
com/amazon/sqs/javamessaging/SQSConnectionFactory.class
Here is how I compile, and the compiler error I get (I use :
in the classpath since I am compiling on Linux):
$ javac -g -encoding utf8 -Xlint:deprecation -classpath '.:download/:download/\*' com/redacted/detectionengine/HandlerFirehose.java
./com/redacted/detectionengine/SqsListenerRunnable.java:3: error: package com.amazon.sqs.javamessaging does not exist
import com.amazon.sqs.javamessaging.SQSConnectionFactory;
^
I am using javac
version 11.0.15.
Since the class com/amazon/sqs/javamessaging/SQSConnectionFactory.class
exists in the JAR in the download
directory, I do not understand why I get this compiler error. As far as I can tell, the classpath argument I provide to javac
is correct.
Edit:
When I try g00se's suggestion, I get this:
$ javac -g -encoding utf8 -Xlint:deprecation -classpath '.:download/amazon-sqs-java-messaging-lib-2.1.1.jar' com/redacted/detectionengine/HandlerFirehose.java
./com/redacted/detectionengine/SqsListenerRunnable.java:3: error: cannot access SQSConnectionFactory
import com.amazon.sqs.javamessaging.SQSConnectionFactory;
^
bad class file: download/amazon-sqs-java-messaging-lib-2.1.1.jar(/com/amazon/sqs/javamessaging/SQSConnectionFactory.class)
class file has wrong version 61.0, should be 55.0
Please remove or make sure it appears in the correct subdirectory of the classpath.