Sitemap
Isakovinc

Isakovinc

Managing Libraries without Maven

3 min readMay 26, 2022

--

Abdulaziz Isakov

Main points

  1. Step by step guidance on how to create your own library in Java
  2. How to use libraries without Maven.

Creating a library

First open a new project and create any class project. 
In our case it will be class Book file.

public class Book {
private String name;
private String author;
private int price;
public Book() {
}
public Book(String name, String author, int price) {
this.name = name;
this.author = author;
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
@Override
public String toString() {
return "Book{" +
"name='" + name + '\\'' +
", author='" + author + '\\'' +
", price=" + price +
'}';
}
}

// Save the class file and open a terminal from intellij.
// (Note that java path should be right to use a terminal.)
Press enter or click to view image in full size
Press enter or click to view image in full size

Make sure you are on the right path here.

Get Isakovinc’s stories in your inbox

Join Medium for free to get updates from this writer.

Our file is in src folder.

Press enter or click to view image in full size
// Then compile the Book.java file.// To compile:     javac *.java   // -->[* means select all to compile]// To make it jar format:          jar cf book-1.2.jar *.class// To compile it with project name --> uz.ntm.libraryTest
// Compile:

javac .\uz\ntm\libraryTest\*.java
// Making it jar type: jar cf book-1.3.jar .\uz\ntm\libraryTest\*.clas

After creating book-1.0.jar → move the file to the folder which will be outside of src folder.

Name it and save all your jar files (libraries ) and make sure to show its path to intellij as well.

Press enter or click to view image in full size

To show the path of your library go to File — Project Structure then press +button then name it and save.

Press enter or click to view image in full size
Press enter or click to view image in full size

Then, go to src and main class file, run something with Book class.

Press enter or click to view image in full size

The same works with all the other libraries. You can download them in jar file and add them to your outer library folder and keep them all there.

Press enter or click to view image in full size

Get all libraries from here by downloading .jar files.

Press enter or click to view image in full size

https://mvnrepository.com/artifact/org.projectlombok/lombok/1.18.22

For more join my channel: JavaStuf

--

--