1
votes

To run the OptaPlanner examples in IntelliJ, I followed the guide in "ReadMeOptaPlanner" in "\optaplanner-distribution-7.23.0.Final":

  1. Open "pom.xml" as project in IntelliJ
  2. Edit Run Configuration.

Nevertheless, I had to change the source and target version manually to avoid errors:

  • File -> Settings -> Build, Execution, Devployment -> Compiler -> Java Compiler -> Per-module bytecode version -> Target bytecode version -> 1.8
  • File -> Project Structure -> Modules -> Sources -> Language level -> 8

But now I get 100 errors when building the code, for example:

Error:(24, 62) java: package org.optaplanner.persistence.common.api.domain.solution does not exist Error:(25, 64) java: package org.optaplanner.persistence.xstream.impl.domain.solution does not exist Error:(53, 12) java: cannot find symbol symbol: class SolutionFileIO location: class org.optaplanner.examples.investment.app.InvestmentApp

or

Error:(24, 48) java: package org.optaplanner.core.api.domain.solution does not exist Error:(25, 39) java: package org.optaplanner.core.api.solver does not exist Error:(26, 39) java: package org.optaplanner.core.api.solver does not exist Error:(32, 62) java: package org.optaplanner.persistence.common.api.domain.solution does not exist Error:(33, 34) java: package org.optaplanner.swing.impl does not exist Error:(34, 34) java: package org.optaplanner.swing.impl does not exist Error:(133, 15) java: cannot find symbol symbol: class Solver location: class org.optaplanner.examples.common.app.CommonApp Error:(149, 21) java: cannot find symbol symbol: class SolutionFileIO location: class org.optaplanner.examples.common.app.CommonApp Information:java: Some input files use unchecked or unsafe operations. Information:java: Recompile with -Xlint:unchecked for details.

or

Error:(23, 44) java: package com.thoughtworks.xstream.annotations does not exist Error:(24, 44) java: package com.thoughtworks.xstream.annotations does not exist Error:(25, 48) java: package org.optaplanner.core.api.domain.solution does not exist Error:(26, 48) java: package org.optaplanner.core.api.domain.solution does not exist Error:(27, 48) java: package org.optaplanner.core.api.domain.solution does not exist Error:(28, 55) java: package org.optaplanner.core.api.domain.solution.drools does not exist Error:(29, 55) java: package org.optaplanner.core.api.domain.solution.drools does not exist Error:(30, 50) java: package org.optaplanner.core.api.domain.valuerange does not exist Error:(31, 50) java: package org.optaplanner.core.api.domain.valuerange does not exist Error:(32, 50) java: package org.optaplanner.core.api.domain.valuerange does not exist Error:(33, 59) java: package org.optaplanner.core.api.score.buildin.hardsoftlong does not exist Error:(36, 74) java: package org.optaplanner.persistence.xstream.api.score.buildin.hardsoftlong does not exist Error:(38, 2) java: cannot find symbol symbol: class PlanningSolution Error:(39, 2) java: cannot find symbol symbol: class XStreamAlias Error:(50, 13) java: cannot find symbol symbol: class HardSoftLongScore location: class org.optaplanner.examples.investment.domain.InvestmentSolution Error:(98, 12) java: cannot find symbol symbol: class HardSoftLongScore location: class org.optaplanner.examples.investment.domain.InvestmentSolution Error:(102, 26) java: cannot find symbol symbol: class HardSoftLongScore location: class org.optaplanner.examples.investment.domain.InvestmentSolution Error:(111, 12) java: cannot find symbol symbol: class CountableValueRange location: class org.optaplanner.examples.investment.domain.InvestmentSolution

Unfortunately the OptaPlanner User Guide only says:

Open the file examples/sources/pom.xml as a new project, the maven integration will take care of the rest.

Thanks!

  • Java: 1.8
  • IDE: IntelliJ IDEA Community Edition 2019.1.3 x64
  • OptaPlanner: 7.23.0
  • OS: Microsoft Windows 10 Enterprise
2
Can you run it via examples/runExamples.bat?Andrey
Make sure the Maven project imported successfully: IDE should download and set up needed dependencies for project. Try refreshing project in Maven Projects tool window. It works fine for me.Andrey
@Andrey: yes, I can run it via examples/runExamples.batoz8qdkj
@Andreay: Refreshed ("Reimport All Maven Projects") it, but all dependencies in the pom.xml are still marked red ("Dependency '...' not found". Is there a way to MANUALLY download and set up the dependencies? (Maybe IntelliJ isnt allowed to access the Internet and download the dependencies within my company?) Thanks!oz8qdkj

2 Answers

0
votes

In Intellij, in the "Maven Projects" side window, check your settings:

enter image description here

Then press these 3 buttons:

enter image description here

0
votes

I had some problems with the company's Proxy, so Maven could not download the needed files inside IntelliJ. Unfortunately it didn't show a message.

Installing and running Maven (outside of IntelliJ) manually and changing its Proxy settings and THEN use IntelliJ as my IDE now works. Thanks for your help.