Tuesday, January 31, 2017

Where and How to download Spring Framework JAR file (Spring 4.0 or Spring 3.2) without Maven, Gradle

One of the easiest and oldest ways to run a Java program which depends on an external library or framework is to download dependency JAR files, put it on the classpath and then run the program by creating a Main class with the main() method. This is simple but not as easy as you think, there are many challenges down the road e.g. you need to find the right version of JAR files and their dependencies e.g. Spring might have a dependency on other third party libraries like Log4j. So, when the build tool like Maven and Gradle comes, everybody stopped downloading the JAR file manually. All they do is specify the Maven dependency and Maven will download the JAR file of specified version along with their dependencies. This greatly simplified the development and testing of Java application which uses a framework like Spring and Hibernate.

But if you are not using Maven or Gradle or doesn't know about them but you want to start with Spring or Hibernate by just downloading their JAR files and putting into classpath where should you go? Traditionally the framework websites also provide download link but Spring's official site, just list Maven dependencies, it doesn't provide a download link to the latest Spring JAR files.

In this article, I am going to share you a trick to download not just Spring but any open source library JAR without using Maven or Gradle or any other dependency management tool.

Download Spring framework JAR from Maven Central Repository.

If you know Maven, you know that Maven downloads all the JAR files from the specified repository, it could be the local nexus repository or public Maven central repository. Maven central host almost all open source libraries and every version of them and the good part are that you can access maven central library by using your web browser without installing Maven.

So, in order to download the Spring framework, just go to maven central website and enter the groupId, artifactId, version, and classifier which you can get from official Spring website and it will then present the download link.

Alternatively, you can also go to the http://maven.springframework.org/release/org/springframework/spring/ and choose the version of Spring framework you want to download e.g. here are direct link to download the latest version of Spring, Spring 4.0 and Spring 3.2 and Spring 2.5

Spring 4.0 - http://maven.springframework.org/release/org/springframework/spring/4.2.0.RELEASE/
Spring 3.2 - http://maven.springframework.org/release/org/springframework/spring/3.2.0.RELEASE/
Spring 2.5 - http://maven.springframework.org/release/org/springframework/spring/2.5/

Though I strongly advise you to spend some time learning Maven or Gradle to manage dependencies in Java project. It will save you tons of times because downloading Spring framework JARs using Maven is as simple ass adding following XML snippet into pom.xml file:


Similar with Gradle, you can add the following link to download Spring framework JAR files:

dependencies {
   compile 'org.springframework:spring-context:4.2.4.RELEASE'

That's all about how to download spring JAR files without using Maven or Gradle in Java project. As I said, you can either download Spring JAR files for any version e.g. Spring 2.5, Spring3.2 and Spring4.2 from Maven central or http://maven.springframework.org. Second one much easier than first one but once you know how to manually search dependency in Maven central repository you can download any JAR file for any open source framework e.g. Hibernate.

Other Spring Framework tutorials you may like
  • Spring HelloWorld Example using XML Configuration (tutorial)
  • Top 5 Spring and Hibernate courses for experienced programmers (list)
  • 5 Books to Learn Spring Framework better (list)
  • How to implement Role based Access Control using Spring Security? (tutorial)
  • How to call a stored procedure from Java using Spring JDBC? (tutorial)
  • How to access a DB connection pool using Spring? (tutorial)
  • What is the difference between BeanFactory vs ApplicationContext in Spring? (answer)
  • What is the difference between Setter vs Constructor Injection in Spring? (answer)

Further Learning
Spring Fundamentals Course
Introduction to Spring MVC 4
Spring in Action 4th Edition 

Thanks for reading this tip, if you like this article then please share with your friends and colleagues. If you have any suggestion or feedback, feel free to drop a comment.

P.S. - If you want to learn how to develop RESTful Web Service using Spring MVC in depth, I suggest you join the REST with Spring master class by Eugen Paraschiv. One of the best course to learn REST with Spring MVC. 


Joel Frederick said...

You could also install SDKMAN (http://sdkman.io). The jars are stored in the .sdkman/springboot/ directory.

Kuba said...

If we really need to download jar manually (maven and gradle are of course always first pick) there is also a nice site which will allow us to download package with jar and all its any potentialy needed dependencies

Post a Comment