Managing Libraries without Maven
Abdulaziz Isakov
Main points
- Step by step guidance on how to create your own library in Java
- 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.)
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.
// 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.
To show the path of your library go to File — Project Structure then press +button then name it and save.
Then, go to src and main class file, run something with Book class.
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.
Get all libraries from here by downloading .jar files.
https://mvnrepository.com/artifact/org.projectlombok/lombok/1.18.22
For more join my channel: JavaStuf







