자바용 OR-도구 Maven 사용
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
소개
이 가이드에서는 간단한 실제 예제를 통해 자바에서 OR-도구를 시작하는 방법을 설명합니다.
이 안내는 다른 Windows 변형에도 적용될 수 있지만 다음 요구사항을 충족하는 컴퓨터에서만 테스트했습니다.
다음을 갖춘 Windows 10 64비트 (x86_64)
- Microsoft Visual Studio Enterprise 2022
- Microsoft Visual Studio Community 2022 Preview 2 이상
기본 요건
다음 섹션에서는 OR-도구를 설치하기 위한 기본 요건을 설명합니다.
Microsoft Visual C++ 재배포 가능
Java용 OR-Tools 라이브러리가 C++ 네이티브 라이브러리의 래퍼이므로 컴퓨터에 Visual Studio 2022용 Microsoft Visual C++ 재배포 가능 패키지 (x64 버전 선택)가 설치되어 있어야 합니다.
Java JDK
또한 Java JDK 64비트 버전 8.0 이상이 설치되어 있어야 합니다.
자세한 내용은 여기를 참고하세요.
Maven
또한 Maven 64비트가 설치되어 있어야 합니다.
자세한 내용은 여기를 참조하세요.
Maven으로 설치
Maven 애플리케이션에 OR-Tools를 포함하려면 아티팩트의 종속 항목을 프로젝트의 pom.xml 파일에 추가합니다. 예를 들면 다음과 같습니다.
<!-- https://mvnrepository.com/artifact/com.google.ortools/ortools-java -->
<dependency>
<groupId>com.google.ortools</groupId>
<artifactId>ortools-java</artifactId>
<version>9.10.4067</version>
</dependency>
Java 예시 코드 가져오기
코드 예는 java_or-tools 저장소에 있습니다.
저장소를 ZIP 파일로 다운로드하고 압축을 풀거나 저장소를 클론합니다.
git clone -b v9.10 --depth 1 https://github.com/or-tools/java_or-tools
예시 디렉터리로 변경합니다.
cd java_or-tools
예시 빌드
java_or-tools
디렉터리에서 다음을 실행합니다.
다음을 사용하여 프로젝트를 빌드합니다.
mvn compile -B
예 실행
java_or-tools
디렉터리에서 다음을 실행합니다.
다음을 사용하여 바이너리를 실행합니다.
mvn exec:java
개업을 축하합니다. OR-도구로 애플리케이션을 실행했으므로 OR-도구를 시작할 준비가 된 것입니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-08-09(UTC)
[null,null,["최종 업데이트: 2024-08-09(UTC)"],[[["\u003cp\u003eThis guide provides step-by-step instructions for setting up and running OR-Tools in Java on Windows 10 64-bit using Maven.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, ensure you have prerequisites like Microsoft Visual C++ Redistributable, Java JDK 8 or later, and Maven installed.\u003c/p\u003e\n"],["\u003cp\u003eYou can integrate OR-Tools into your Maven project by adding a dependency to your project's \u003ccode\u003epom.xml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eExample code is available in the \u003ccode\u003ejava_or-tools\u003c/code\u003e repository on GitHub and can be built and run using Maven commands.\u003c/p\u003e\n"],["\u003cp\u003eAfter successfully running the example, you can explore further functionalities and features of OR-Tools for your Java applications.\u003c/p\u003e\n"]]],["This guide details how to use OR-Tools in Java. Key actions include installing prerequisites: the Microsoft Visual C++ Redistributable (x64), a 64-bit Java JDK (8.0+), and 64-bit Maven. To integrate OR-Tools, add its artifact dependency to the project's pom.xml file. Download or clone the `java_or-tools` repository, navigate to its directory, and then build the project with `mvn compile -B`. Finally, execute the example by running `mvn exec:java`.\n"],null,["# Using OR-Tools Maven for Java\n\nIntroduction\n------------\n\nThis guide gets you started with OR-Tools in Java with a simple working\nexample.\n\nAlthough these instructions might also work on other Windows variants, we\nhave only tested them on machines meeting the following requirements:\n\n\nWindows 10 64-bit (x86_64) with:\n\n- Microsoft Visual Studio Enterprise 2022\n- Microsoft Visual Studio Community 2022 Preview 2 or above\n\n\u003cbr /\u003e\n\nPrerequisites\n-------------\n\nThe following sections describe the prerequisites for installing OR-Tools.\n\n### Microsoft Visual C++ Redistributable\n\nYou must have the\n[Microsoft Visual C++ Redistributable for Visual Studio 2022](https://visualstudio.microsoft.com/downloads/?q=Visual+C%2B%2B+Redistributable+for+Visual+Studio) (select the x64 version) installed\non your computer, since OR-Tools library for Java is a wrapper for the\nC++ native library.\n\n### Java JDK\n\nYou must also have a Java JDK 64 bit, version 8.0 or later installed.\n\nYou can find more details\n[here](https://java.com/en/download/help/download_options.xml).\n\n### Maven\n\nYou must also have a Maven 64 bit installed.\n\nYou can find more details [here](https://maven.apache.org/download.cgi).\n\nInstalling with Maven\n---------------------\n\nTo include OR-Tools in your Maven application, add a dependency on its artifacts\nto your project's pom.xml file. For example, \n\n \u003c!-- https://mvnrepository.com/artifact/com.google.ortools/ortools-java --\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.ortools\u003c/groupId\u003e\n \u003cartifactId\u003eortools-java\u003c/artifactId\u003e\n \u003cversion\u003e9.12.4544\u003c/version\u003e\n \u003c/dependency\u003e\n\nGet the Java example code\n-------------------------\n\nThe example code is located in the\n[java_or-tools](https://github.com/or-tools/java_or-tools) repository.\n\n1. [Download the repository as a zip file](https://github.com/or-tools/java_or-tools/archive/v9.12.zip)\n and extract it, or clone the repository:\n\n git clone -b v9.12 --depth 1 https://github.com/or-tools/java_or-tools\n\n2. Change to the examples directory:\n\n cd java_or-tools\n\nBuild the example\n-----------------\n\nFrom the `java_or-tools` directory:\n\nBuild the project using:\n\n\n mvn compile -B\n\n\u003cbr /\u003e\n\nRun the example\n---------------\n\nFrom the `java_or-tools` directory:\n\nRun the binary using:\n\n\n mvn exec:java\n\n\u003cbr /\u003e\n\nCongratulations! You've just run an application with OR-Tools, you are ready to\n[get started with OR-Tools](../../introduction/java)."]]