Compile Cplex in Java in linux

心不动则不痛 提交于 2019-12-06 01:37:09

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

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

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.

Whether on Windows, Linux, OS X, or any other OS, the Java compiler needs to know where to look for the classes used by your program but not included among its sources. It uses the classpath for that purpose.

How the contents of the classpath are determined is a bit complex, and it can have implementation-specific details, but for your particular case you should probably just use the -cp option to javac to tell it where to find the needed classes:

javac -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar file.java
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!