在Linux中用Java编译Cplex

在Linux中用Java编译Cplex

本文介绍了在Linux中用Java编译Cplex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在具有使用Linux(我是Windows用户)和已使用(通过和应用程序发送命令)的集群中使用CPLEX表示法的优化问题来编译我的file.java.

i'm trying to compile my file.java with an optimization problem with CPLEX notation in a cluster wich use linux (an i'm a windows user) and a used (through and application to send commands)

javac file.java

我收到类似:

        file.java:4: error: package ilog.concert does not exist
        import ilog.concert.IloException;
                           ^
        file.java:5: error: package ilog.concert does not exist
        import ilog.concert.IloLinearNumExpr;
                           ^
        file.java:6: error: package ilog.concert does not exist
        import ilog.concert.IloNumVar;
                           ^
        file.java:7: error: package ilog.concert does not exist
        import ilog.concert.IloNumVarType;
                           ^
        file.java:8: error: package ilog.concert does not exist
        import ilog.concert.IloRange;
                           ^
        file.java:9: error: package ilog.cplex does not exist
        import ilog.cplex.IloCplex;

因此它无法识别群集中这种泛滥的库(因此也包括导入)

So it don't recognize the library (and therefore the imports) wich is supposedly in this ubication in the cluster

  /home/apps/cplex/12.6.1/cplex/lib/cplex.jar

我的问题是,我是否必须在javac命令行中添加某些内容,或者未连接路径(例如int Windows)?

My question is, do I have to add something to the javac command line or is not connected the paths (like int Windows)?

推荐答案

使用-cp命令行参数将jar文件添加到编译时的类路径中.您也需要在运行代码时指定类路径.

Use the -cp command line argument to add the jar file to your compile-time classpath. You'll need to specify the classpath when you run the code too.

$ javac -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar file.java
$ java -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar:. file

理想情况下,开始使用Java软件包而不是默认软件包,并遵循Java命名约定.

Ideally, start using Java packages rather than the default package, and follow Java naming conventions.

此外,如果您不熟悉Java入门,那么在尝试运行诸如此类的复杂程序之前,我会阅读一些教程等.

Also, if you're not familiar with Java to start with, I would read some tutorials etc before you start trying to run anything complex like this.

这篇关于在Linux中用Java编译Cplex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 07:36