First, English is not my first language, so there are might some wired syntax in my question.
I want to follow this workflow for my programming skill.
My problem is disappearing jar file when I use gradle-build or run static main method
anyway, I prepared some source.
// src/../demo/Library
public class Library {
// The method just for library import test
public int add(int a, int b) {
return a + b;
}
}
build/libs/lib.jar
.๐test-project
|--๐ src
|----๐ main
|------๐ java
|--------๐ org.test
|----------๐ LibraryTest.java
|-- build.gradle
|-- setting.gradle
Project Structure > Modules > + button(Add) > JARs or Directories...
.So... this is result screenshot enter image description here
It looks correct, and right. 'lib.jar' is imported and LibraryTest class can using Library's method 'add(...)'. But if I run LibraryTest.main method, then lib.jar is disappear and occur build errors
.../test-project/src/main/java/org/test/LibraryTest.java:3:12
java: package demo does not exist
.../test-project/src/main/java/org/test/LibraryTest.java:9:9
java: cannot find symbol
symbol: class Library
location: class org.test.LibraryTest
How can I resolve this problems...??
I tried to searching 'create java library', and I'm just expecting right result without import errors
IDE uses Gradle build file as initial source for project configuration. So, if dependency is missing in build file it will be removed on reload. Please add it to build file: https://www.baeldung.com/gradle-dependencies-local-jar