no jsmile in java.library.path - java

I am getting exception : no jsmile in java.library.path when i run my project. Even i have added jsmile_win64 in lib folder and .dll file in vm option : -Djava.library.path="C:\Users\admin\jsmile.dll"; But still I am facing the same issue.
import smile.Network;
import smile.learning.DataMatch;
import smile.learning.DataSet;
import smile.learning.EM;
import smile.learning.GreedyThickThinning;
public class MyClass
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Network _net = new Network();
_net.readFile(workfilehere);
}
}
How to fix this?

It works fine after changed the -Djava.library.path="C:\Users\admin\jsmile.dll"; to -Djava.library.path="C:\Users\admin\"

Related

jcurses errors while try to import in IntelliJ

I`m trying to import jcurses library to IntelliJ but get an error.
File -> Project Structure -> Modules -> import jar file.
Then in code:
import jcurses.widgets.Window;
class main {
public static void main(String[] args){
Window win = new Window(800, 600, true, "test");
win.setVisible(true);
}
Exception in thread "main" java.lang.ExceptionInInitializerError
at jcurses.system.InputChar.<clinit>(InputChar.java:25)
at jcurses.widgets.Window.<clinit>(Window.java:209)
at main.main(main.java:7)
Caused by: java.lang.RuntimeException: couldn't find jcurses library
at jcurses.system.Toolkit.getLibraryPath(Toolkit.java:121)
at jcurses.system.Toolkit.<clinit>(Toolkit.java:37)
Could someone point out where is my mistake?
Thanks in advance!
The answer is that dll must be in the same directory as jar file. Thanks to everyone!
Libray download url
https://sourceforge.net/projects/javacurses/files/javacurses/0.9.5/
The path of the library is in the root directory of the project
dynamically add the library
import java.io.File;
import java.lang.reflect.Field;
import java.util.Arrays;
public class LoadLibrary {
public static void main(String cor[]) throws Exception {
// Cargando librerias necesarias
loadLibraryJCourses();
}
public static void loadLibraryJCourses() throws Exception{
loadDynamicLibrary(new File("lib/bin/jcourses/").getAbsolutePath(),"libjcurses64");
}
private static void addLibraryPath(String pathToAdd) throws Exception {
final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths");
usrPathsField.setAccessible(true);
//get array of paths
final String[] paths = (String[]) usrPathsField.get(null);
//check if the path to add is already present
for (String path : paths) {
if (path.equals(pathToAdd)) {
return;
}
}
//add the new path
final String[] newPaths = Arrays.copyOf(paths, paths.length + 1);
newPaths[newPaths.length - 1] = pathToAdd;
usrPathsField.set(null, newPaths);
}
private static void loadDynamicLibrary(String pathLibraryDirectory, String libraryName) throws Exception{
File pathLibraryFile = new File(pathLibraryDirectory);
addLibraryPath(pathLibraryFile.getAbsolutePath());
System.loadLibrary(libraryName);
}
}

Rserve - Eclipse & Java

Hi I am setting up rserve based on the instructions on this website.
http://www.codophile.com/how-to-integrate-r-with-java-using-rserve/
However in eclipse I am getting an error when using 'eval'
double d[] = c.eval("rnorm(10)").asDoubles();
error - 'The method eval(String) is undefined for the type RConnection'
The JARS have been correctly loaded into the build path and rserve is running, however I cannot figure out why only the eval function is causing an issue.
In addition to this the import of ...
import org.rosuda.REngine.Rserve.RConnection;
causes an error - 'The import org.rosuda.REngine.Rserve.RConnection conflicts with a type defined in the same file'
does anyone have any idea why this is the case? Thanks
all imports :
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;
public class RConnection {
public int[] mean(String a[]) {
setupR();
return null;
}
public void setupR(){
try {
/* Create a connection to Rserve instance running
* on default port 6311
*/
RConnection c = new RConnection();// make a new local connection on default port (6311)
double d[] = c.eval("rnorm(10)").asDoubles();
org.rosuda.REngine.REXP x0 = c.eval("R.version.string");
System.out.println(x0.asString());
} catch (RserveException e) {
e.printStackTrace();
} catch (REXPMismatchException e) {
e.printStackTrace();
}
}
}
By using import org.rosuda.REngine.Rserve.RConnection; you are tying to make RConnection known in the local namespace.
However, you already defined a class called RConnection locally.
Please rename your class RConnection, and you should be able to import org.rosuda.REngine.Rserve.RConnection.

Endpoint publisher in java does not work

I have the following webservice :
package testSmart;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
#WebService(name="AddHM", portName="prtNameHM", serviceName="srvNameHM", targetNamespace="hm.com")
#SOAPBinding(style=Style.RPC)
public class add {
AddBusinessLogic add=new AddBusinessLogic();
#WebMethod(action="GoAdd", operationName="Go_AddNumber")
public int addNum(int i, int j) {
return add.addNum(i, j);
}
}
which works perfectly fine with glassfish.
then I stopped glassfish and use the following code to make my server :
import javax.xml.ws.Endpoint;
public class publisher {
public static void main(String[] args) {
// TODO Auto-generated method stub
Endpoint.publish("http://localhost:1234/add", new add());
}
}
Now when I try this link:
http://localhost:1234/add
Nothing happens and the browser says no data received.
Even after trying different port the same problem exist.
Can anyone help me how to fix it?
Call to http://localhost:1234/add will not get you anything because there is no specific document with that URI that browser can get. But if you type
http://localhost:1234/add?wsdl
you should get the generated wsdl document.

Not able to connect to ARServer

Here is my code:
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.ARServerUser;
public class ARServer {
public static void main(String[] args) {
ARServerUser ar = new ARServerUser();
ar.setServer("ServerName");
ar.setUser("Username");
ar.setPassword("Password");
ar.connect();
ar.login();
try {
ar.verifyUser();
} catch (ARException e) {
System.out.println(e.getMessage());
}
}
}
I have created build path for this jar file "ardoc7604_build002.jar" but still i am getting errors like:
import com.bmc.arsys.api.ARException can not be resolved
import com.bmc.arsys.api.ARServerUser; can not be resolved
ARserver can not be resolved
ARException can not be resolved to a type.
Thanks in advance for help.
you have put the javadoc jar in your path - you need to use the java api jar instead.
arapi7604_build002.jar
are you Only Java person or do you understand C# aswell if so I can give you some examples

Could not find main class Java

I have two classes Pair.java and Users.java where Users.java has the main program. Both these java files are under the package userdetails.
In unix,
I compiled it using the command
javac -d . -classpath avro-1.7.5.jar:lib/*:jackson-core-asl-1.9.13.jar:lib/* Pair.java Users.java
the class are under the folder userdetails.
I tried to run using the command
java -classpath avro-1.7.5.jar:lib/*:jackson-core-asl-1.9.13.jar:lib/* userdetails.Users
I'm getting error
Could not find main class userdetails.Users
Kindly help me.
source code :-
import java.io.File;
import java.io.IOException;
import org.apache.avro.file.DataFileReader;
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.io.DatumReader;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.specific.SpecificDatumReader;
import org.apache.avro.specific.SpecificDatumWriter;
import org.apache.avro.util.Utf8;
public class Users {
public void createUser() {
userdetails.Pair datum = new userdetails.Pair(new Utf8("L"), new Utf8("R"));
DatumWriter writer = new SpecificDatumWriter();
DataFileWriter fileWriter = new DataFileWriter(writer);
try {
fileWriter.create(datum.getSchema(), new File("users.avro"));
fileWriter.append(datum);
System.out.println(datum);
fileWriter.close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("ERROR");
e.printStackTrace();
} }
public static void main(String[] args) {
Users user = new Users();
user.createUser();
}
}
When you specify a classpath, the current working directory is not automatically contained any more, so you must add it to the classpath:
java -classpath avro-1.7.5.jar:lib/*:jackson-core-asl-1.9.13.jar:lib/*:. userdetails.Users
You say both classes are under the package "userdetails", but there is no package declaration at the beginning of your source. Both Pair.java and User.java should begin with the line:
package userdetails;
Check out the Java Packages Tutorial

Categories

Resources