Eclipse에 포함 된 외부 라이브러리로 jar를 만드는 방법은 무엇입니까?
데이터베이스 (MySQL)에 연결하는 프로젝트를 완료했습니다. 이제 프로젝트를 jar로 내보내고 싶습니다. 하지만 외부 종속성을 포함하는 방법을 모르겠습니까? Eclipse에서 수행하는 방법이 있습니까? 아니면 스크립트를 사용해야합니까?.
프로젝트를 'Runnable jar'로 내보낼 때 (프로젝트에서 마우스 오른쪽 버튼-> Export-> Runnable jar) 생성 된 jar에 모든 종속성을 패키징하는 옵션이 있습니다. 또한 라이브러리를 내보내는 두 가지 다른 방법 (스크린 샷 참조)이 있습니다. 사용할 패키징 방법을 결정할 때 라이선스를 알고 있어야합니다.
'시작 구성'드롭 다운은 main(String[])
메서드가 포함 된 클래스로 채워집니다 . 선택한 클래스는 항아리를 '실행'할 때 시작됩니다.
Exporting as a runnable jar uses the dependencies on your build path (Right mouse on project -> Build Path -> Configure Build Path...). When you export as a 'regular' (non-runnable) jar you can select any file in your project(s). If you have the libraries in your project folder you can include them but external dependencies, for example maven, cannot be included (for maven projects, search here).
You could use the Export->Java->Runnable Jar to create a jar that includes its dependencies
Alternatively, you could use the fatjar eclipse plugin as well to bundle jars together
You can right-click on the project, click on export, type 'jar', choose 'Runnable JAR File Export'. There you have the option 'Extract required libraries into generated JAR'.
Personally,
None of the answers above worked for me, I still kept getting NoClassDefFound errors (I am using Maven for dependencies). My solution was to build using "mvn clean install" and use the "[project]-jar-with-dependencies.jar" that that command creates. Similarly in Eclipse you can right click the project -> Run As -> Maven Install and it will place the jars in the target folder.
If you want to export all JAR-files of a Java web-project, open the latest generated WAR-file with a ZIP-tool (e.g. 7-Zip), navigate to the /WEB-INF/lib/ folder. Here you will find all JAR-files you need for this project (as listed in "Referenced Libraries").
To generate jar file in eclipse right click on the project for which you want to generate, Select Export>Java>Runnable Jar File,
Its create jar which includes all the dependencies from Pom.xml, But please make sure license issue if you are using third-party dependency for your application.
While exporting your source into a jar, make sure you select runnable jar option from the options. Then select if you want to package all the dependency jars or just include them directly in the jar file. It depends on the project that you are working on.
그런 다음 java -jar example.jar로 jar를 직접 실행합니다.
독립형 (주요 방법) 자바 프로젝트 인 경우 특정 경로가 아닌 특정 경로가 아닌 프로젝트 내부에 모든 항아리를 넣은 다음 프로젝트를 마우스 오른쪽 버튼으로 클릭-> 내보내기-> 실행 가능한 항아리-> 점심 구성 및 라이브러리 처리를 선택하십시오. 그런 다음 "필요한 라이브러리를 생성 된 jar에 패키징"라디오 버튼 옵션-> 완료를 선택하십시오.
또는
웹 프로젝트가있는 경우 모든 jar를 web-inf / lib 폴더에 넣고 동일한 단계를 수행합니다.
'developer tip' 카테고리의 다른 글
C # : 개체 목록을 해당 개체의 단일 속성 목록으로 변환하는 방법은 무엇입니까? (0) | 2020.09.14 |
---|---|
Sphinx의 autodoc을 사용하여 클래스의 __init __ (self) 메서드를 문서화하는 방법은 무엇입니까? (0) | 2020.09.14 |
Swift에서 뷰 컨트롤러와 다른 객체간에 데이터를 어떻게 공유합니까? (0) | 2020.09.14 |
.json ()이 프라 미스를 반환하는 이유는 무엇입니까? (0) | 2020.09.14 |
스택 변수가 GCC __attribute __ ((aligned (x)))에 의해 정렬됩니까? (0) | 2020.09.14 |