Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Adding aws jar to classpath

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I am coding a standalone java executable to test a file upload to s3. However, I am confused over how to download the aws java packages (com.amazonaws.*). I can't seem to find an aws jar anywhere. Does anybody know how to download it? thank you very much.
 
Saloon Keeper
Posts: 24540
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probable the easiest way to do that is to use Maven to build your executable JAR. Maven can automatically include those jars as dependencies.

For the names and versions that Maven supports, see here: https://search.maven.org/search?q=com.amazonaws
 
Sheriff
Posts: 22508
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the official "Get started" guide for Java: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html. It also recommends Maven.
 
Thomas Griffith
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been reading about Maven. Is Mavan basically a utility to build a custom jar and dump that jar into the classpath?
 
Tim Holloway
Saloon Keeper
Posts: 24540
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maven is a general-purpose Java artefact build tool. Artefact types include JARs, WARs, EARS, and a lot of other things. It is especially useful for creating webapps. It is one of the most commonly used build tools for major open-source and commercial projects and it works quite nicely alongside of IDEs like Eclipse and IntelliJ and with continous-integration sysems like Jenkins. It's can automaticallt download and cache public libraries such as the AWS JARs that you're interested in and will automatically include them in the artefact you build.

There is no such thing as "the classpath". Every process on every machine that runs Java has its own classpath, and many systems such as webapp servers generate multiple internal classpaths. What you actually want to is create an aterfact (executable JAR?) and deploy it to S3. S3 is an object storage system, though and is not an executable environments, has no processes as such and thus no classpath. I think I asked about this in another thread. since simply sending a jar to S3 seems kind of a useless thing to do by itself.

See https://maven.apache.org
 for more information about Maven.
 
Thomas Griffith
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much, Tim. I guess I'm looking for an executable aws jar to put in the classpath for a standalone java program (on my windows) to import aws packages and test coding/uploading to s3. Similar to the oracle driver jar, for example, or any other external jars for java programs. It's also something ultimately I'd like to code for a lotus notes agent where you add exernal jars to agents. It's not a custom webapp yet.
 
Tim Holloway
Saloon Keeper
Posts: 24540
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what you mean is that you're writing a Java application that will run on your client's machine and you want to make sure that the Amazon classes you need are in the application's classpath, correct? Not that you're actually expecting to run an app from inside S3 itself.

The tidiest way of doing that would be to use Maven to create an executable JAR where the S3 libraries would be part of that executable JAR. That puts everything into one bundle and you can simply execute the JAR using the "java" command.

However, you'd need to know how to use Maven and how to tell it that you wanted an executable JAR and I think that may be more than you are currently up to.

Failing that, you'd do it the hard way. Download copies of the S3 libraries that you need and include them in the classpath when you run the Java application. If your application is compiled classes, that would be a command line such as the following:

java -classpath ./classes;aws-java-sdk-s3-1.12.94.jar com.thomasgriffith.my.s3.app.MainClass

Where "./classes" would be the directory you compiled your classes in, and I'm inventing a package name structure of com.thomasgriffith.my.s3.app just because it's good practice. Your source directory layout and the package directives in your source classes would have to match that, of course.

Note, incidentally, that where I've used semicolons on the sample java command line, that's how your do it in Windows. A Unix, Linux or MacOS machine would use colons, instead.
 
Thomas Griffith
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Download copies of the S3 libraries that you need and include them in the classpath when you run the Java application.



yeah, right now I'm just trying to "proof of concept" this. I guess my question is still where can I download the aws libraries? I can't find anywhere to get these in a compressed format. I've found a few jars here or there on mirror sites and look inside and they are aws maven classes.
 
Tim Holloway
Saloon Keeper
Posts: 24540
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the definitive copies are provided by AWS themselves. However, the example library I showed can also be downloaded manually from the Maven Repository at the URL I provided previously. Maven normally downloads automatically, but in case of trouble (or if you're not using Maven) you can also do it yourself by clicking on the HTTP link/button.

You won't find "compressed jars". A Java JAR file is nothing but a ZIP file with a META-INF directory to hold Java-specific information. So in other words, a JAR is already compressed by definition. JARs are typically class containers, so their primary contents are usually class files. Java knows to treat those classes just like they would any other directory full of classes in the CLASSPATH if you put the JAR file in your CLASSPATH. Note, however, that JARs within JARs will NOT be considered as part of the classpath nor will any classes within them.

That's the basic rule for JARs. WARs are Web Application Archives, and their layout is quite different, but they too are ZIP files. Basically any Java file whose name ends with "AR" is based on ZIP.
reply
    Bookmark Topic Watch Topic
  • New Topic