Using jshell with libraries
Sam Pullara
spullara+kulla-dev at gmail.com
Tue Mar 20 22:26:47 UTC 2018
Hi all,
I don't know if you all have talked this to death but the jshell as it
exists today isn't that useful to me because almost all my use cases
require either 3rd party libraries or local code. Downloading the code and
setting the classpath in each environment I want to use it doesn't seem
that great. So instead, I have been using a jshell variant:
https://github.com/kawasima/try-artifact . The variant lets me easily add
3rd party dependencies in the shell from the central maven repository so
you can do things like:
| Welcome to JShell -- Version (version info not available)
| Type /help for help
-> /resolve com.amazonaws:aws-java-sdk-s3:1.11.297
| Path /Users/sam/.m2/repository/com/amazonaws/aws-java-sdk-s3/1.11
.297/aws-java-sdk-s3-1.11.297.jar added to classpath
| Path /Users/sam/.m2/repository/com/amazonaws/aws-java-sdk-kms/1.1
1.297/aws-java-sdk-kms-1.11.297.jar added to classpath
| Path /Users/sam/.m2/repository/com/amazonaws/aws-java-sdk-core/1.
11.297/aws-java-sdk-core-1.11.297.jar added to classpath
| Path /Users/sam/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar
added to classpath
| Path /Users/sam/.m2/repository/org/apache/httpcomponents/httpclient/4.5.5/httpclient-4.5.5.jar
added to classpath
| Path /Users/sam/.m2/repository/org/apache/httpcomponents/httpcore/4.4.9/httpcore-4.4.9.jar
added to classpath
| Path /Users/sam/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar
added to classpath
| Path /Users/sam/.m2/repository/software/amazon/ion/ion-java/1.0.2/ion-java-1.0.2.jar
added to classpath
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson
-databind/2.6.7.1/jackson-databind-2.6.7.1.jar added to classpath
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson
-annotations/2.6.0/jackson-annotations-2.6.0.jar added to classpath
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson
-core/2.6.7/jackson-core-2.6.7.jar added to classpath
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/dataformat/j
ackson-dataformat-cbor/2.6.7/jackson-dataformat-cbor-2.6.7.jar added to
classpath
| Path /Users/sam/.m2/repository/joda-time/joda-time/2.8.1/joda-time-2.8.1.jar
added to classpath
| Path /Users/sam/.m2/repository/com/amazonaws/jmespath-java/1.11.297/jmespath-java-1.11.297.jar
added to classpath
-> var s3 = new com.amazonaws.services.s3.AmazonS3Client()
| Added variable s3 of type com.amazonaws.services.s3.AmazonS3Client with
initial value com.amazonaws.services.s3.AmazonS3Client at 463b4ac8
Which is obviously much easier than downloading the artifacts and managing
the classpath. Has there been much thought in adding something like this to
the jshell that comes with the JDK?
Sam
More information about the kulla-dev
mailing list