I have a newbie problem with taking the Cplex library in Eclipse,
Error: Could not find or load main class Files\IBM\ILOG\CPLEX_Studio1210\cplex\bin\x64_win64
Caused by: java.lang.ClassNotFoundException: Files\IBM\ILOG\CPLEX_Studio1210\cplex\bin\x64_win64
I added cplex.jar from external libraries and also added the native path by editing it,
CPLEX library path error in eclipse
under VMArguments I added,
-Djava.library.path=C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\bin\x64_win64
where cplex12100.dll stands. I managed to work with it before but I couldn't find why it is not working right now.
Everything is 64bit.
Thanks in advance!
Your error message references the following path:
Files\IBM\ILOG\CPLEX_Studio1210\cplex\bin\x64_win64
Notice that it does not start with "C:Program Files". My guess is that you need to put quotes around the path you are providing, like so:
-Djava.library.path="C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\bin\x64_win64"
This should allow Java to handle your path which includes a space character.
thanks for the answer,
Unfortunately, I forgot to add that I already tried that, but it gives another error when I try like that.
Error: Unable to initialize main class model(my package name).model(my class name)
Caused by: java.lang.NoClassDefFoundError: ilog/concert/IloException
Here is part of my code, I cut half of it(after ...) since I guess it is unrelated to the question.
package model;
import ilog.concert.*;
import ilog.cplex.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.*;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
public class model {
public static void main(String[] args) throws Exception {
long startTime = Instant.now().toEpochMilli();
int a = 45; //matrisin boyutu
int b = 45; //matrisin 2. boyutu
int maxdistance = 90; //mesela 90 dan küçük deðerler
int depot = 0;
double alfa = 0.9;
double beta = 0.1;
float[][] distance = new float[a][b]; // bunu scanner dan çektik
int m = 3;
int C = 1200;
System.out.println();
System.out.println("m : " + m + " C : " + C );
System.out.println();
ArrayList<ArrayList> Nlist = new ArrayList<ArrayList>();
Scanner reader = null;
File burdurData = new File("burdur45.txt");
...
try {
long timeElapsed = endTime - startTime;
System.out.println("Execution time in milliseconds: " + timeElapsed);
System.out.println("Execution time in seconds: " + timeElapsed/1000);
} // try'ýn parantezi
catch (IloException exc) {
System.out.println(exc);
System.out.println("sýkýntý");
}
}
}
surely you should edit your question. In fact, for getting error:
java.lang.NoClassDefFoundError: ilog/concert/IloException
I had this error before and I solved it just by importing cplex.jar in ClassPath section of my project Java Build Path not in ModulePath. Also set Native Library Location path to cplex's dlls folder too. Furthermore you can check your details in java configuration->show command line too.
Related
I think I trying to solve this problem for any ways such as: CLASSPATH is wrong, Remove cache file , Restart.. etc...
BUT One interesting issues: I got fixed when I trying to add Libraries' New Java(such as spigot-1.17.1.jar) and Edit Modules Dependencies(Scope section) Normal Provided(Maven: org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT) -> Compile
Then this got fixed BUT I DON'T KNOW WHY THIS WORKING TO ME
EXPLAIN:
First of all, When I click(application menu) and press RUN button then I got this msg:
Error: Could not find or load main class me.kennytool.betaplugin.BetaPluginHandler.
Caused by: java.lang.NoClassDefFoundError: org/bukkit/event/Listener
package me.kennytool.betaplugin;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class BetaPluginHandler implements Listener {
public static void main(String[] args) {
}
#EventHandler
public void onJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
if (player.hasPlayedBefore()){
e.setJoinMessage(ChatColor.AQUA + "[REJOIN]" + ": " + ChatColor.BOLD + player.getDisplayName() + ChatColor.YELLOW + " WELCOME BACK");
// Have experienced logging log
}else{
e.setJoinMessage(ChatColor.YELLOW + "[FIRST]" + ": " + ChatColor.BOLD + player.getDisplayName() + ChatColor.BLUE + " WELCOME FIRST!");
// First logging on!
}
}
}
I don't know why this error shows to me.... Too many solution got it to solve this problems but this not WORK to me
NOTE: I used Java and with Minecraft Development Kit(Spigot)
(This probs doesn't occur in plain Java Project)
From your screenshots, all the dependencies are marked as scope provided, this means that they are expected to be provided externally and not available on the classpath. Please provide the contents of your pom.xml to verify, but I suspect you'll find a line on your dependencies that reads something like <scope>provided</scope> deleting this should resolve the issue. You can read more about maven dependency scopes here: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#dependency-scope
I have taken a written sample from this link to write my Python + Java integration code.
http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html
The code looks like below.
package org.jython.book.interfaces;
import org.jython.book.interfaces.JythonObjectFactory;
import org.python.core.Py;
import org.python.core.PyString;
import org.python.core.PySystemState;
public class Main {
public static void main(String args[]) {
String projDir = System.getProperty("user.dir");
String rootPath = projDir + "/src/org/jython/book/interfaces/";
String modulesDir = projDir + "/src/org/jython/book/interfaces/";
System.out.println("Project dir: " + projDir);
PySystemState sysSt = Py.getSystemState();
JythonObjectFactory factory = new JythonObjectFactory(sysSt, BuildingType.class, "Building", "Building");
BuildingType building = (BuildingType) factory.createObject();
building.setBuildingName("BUIDING-A");
building.setBuildingAddress("100 MAIN ST.");
building.setBuildingId(1);
System.out.println(building.getBuildingId() + " " +
building.getBuildingName() + " " +
building.getBuildingAddress());
}
}
When I run this code, it throws an error that it did not find the python module. I have kept the .py and .pyc files under the path provided as 'modulesDir'.
The literature says that "the requested module must be contained somewhere on the sys.path"; however, I did not understand how this can be set from this Java program. Can someone please provide some help?
Project dir: /Users/eclipsews/PythonJava
Exception in thread "main" ImportError: No module named Building
Hi found the answer to this issue!
Added the PySystemState.initialize method where I explicitly provide the "python.path" property, which is initialized to my project's path, where python modules are available.
private static Properties setDefaultPythonPath(Properties props) {
String pythonPathProp = props.getProperty("python.path");
String new_value;
if (pythonPathProp == null) {
new_value = System.getProperty("user.dir") + "/src/org/jython/book/interfaces/";
}
props.setProperty("python.path", new_value);
return props;
}
Properties props = setDefaultPythonPath(System.getProperties());
PySystemState.initialize( System.getProperties(), props, null );
This produces the correct output as follows:
module=<module 'Building' from '/Users/eclipsews/PythonJava/src/org/jython/book/interfaces/Building$py.class'>,class=<class 'Building.Buildin
g'>
1 BUIDING-A 100 MAIN ST.
Im tring to run this example from the Renjin website, http://www.renjin.org/documentation/developer-guide.html , im tring to run the first "A simple primer" example.
following is my directory layout:
And here is my code:
package stackoverflow;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import org.renjin.sexp.*; // <-- import Renjin's object classes
/**
*
* #author yschellekens
*/
public class StackOverflow {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
// create a Renjin engine
ScriptEngine engine = factory.getEngineByName("Renjin");
// evaluate R code from String, cast SEXP to a DoubleVector and store in the 'res' variable
DoubleVector res = (DoubleVector)engine.eval("a <- 2; b <- 3; a*b");
System.out.println("The result of a*b is: " + res);
}
}
Why am i getting the following Exception? (i should get of 6)
run:
Exception in thread "main" java.lang.NullPointerException
at stackoverflow.StackOverflow.main(StackOverflow.java:22)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
thanks in advance
The exception is throw because your application can't find the Renjin ScriptEngine. You have provided renjin-studio as a library, but you need the renjin-script-engine library which is available from http://build.bedatadriven.com/job/renjin/lastSuccessfulBuild/org.renjin$renjin-script-engine/ (use the JAR with dependencies).
Unfortunately ScriptEngineManager.getEngineByName() only returns null if it can't find the engine so you can add the following check to ensure that the engine has loaded:
// check if the engine has loaded correctly:
if(engine == null) {
throw new RuntimeException("Renjin Script Engine not found on the classpath.");
}
Also note: it is called Renjin, not Rengin!
I am receiving a Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: error in netbeans when I try to run the code below. I am supposed to input from a file and then display the data using the formulas below in the output window. I don't see any errors that are given with the code itself until I try to run the code. I am new to Java and having a hard time grasping some of the concepts. I have cleared out the netbeans cache and restarted and now am getting this error. Thanks for any help.
package input.from.a.file.broc.east;
public class InputFromAFileBrocEast
{
public static void main(String[] args)
{
String name;
int hours;
int rate;
int grossPay;
InputFile wageFile;
wageFile = new InputFile("payroll.txt");
while (!wageFile.eof())
{
name = wageFile.readString();
hours = wageFile.readInt();
rate = wageFile.readInt();
if (hours <= 40)
{
grossPay = (rate * hours);
System.out.println("grossPay");
}
else
{
grossPay = (int) ((rate * 40) + (hours-40) * 1.5 * rate);
System.out.println("Gross Pay: " + grossPay);
}
}
}
}
Netbeans allows you to run the code even if certain classes are not compilable. During the application's runtime, if you access this class it would lead to this exception.
To ensure you get the exact compilation error, you need to deselect 'Compile On Save' in the project options.
Also have a look at https://netbeans.org/bugzilla/show_bug.cgi?id=199293
Hi I'm trying to make a game in java that gives users the option to a joystick or gamepad to control movement. So I found something called "JInput" that is suppose to make it easy to detect all connected game controllers. The problem is that when I run it in Eclipse I get the following error: "java.lang.UnsatisfiedLinkError: no jinput-dx8 in java.library.path".
My code is the following:
import net.java.games.input.*;
public class ListControllers
{
public static void main(String[] args)
{
System.out.println("JInput version: " + Version.getVersion());
ControllerEnvironment ce =
ControllerEnvironment.getDefaultEnvironment();
Controller[] cs = ce.getControllers();
if (cs.length == 0) {
System.out.println("No controllers found");
System.exit(0);
}
// print the name and type for each controller
for (int i = 0; i < cs.length; i++)
System.out.println(i + ". " +
cs[i].getName() + ", " + cs[i].getType() );
} // end of main()
} // end of ListControllers class
I'm currently developing in Windows 7 environment. Any help would be really appreciated.
You should set java.library.path property to point to the directory containing native dlls of JInput.
You can do it by adding -Djava.library.path=x (where x is your path) to the command line or to the "VM arguments" field of "Run configurations" dialog in Eclipse.