I wrote this simple code:
public class Test {
public static void main(String args[]) {
OculusRift oculusRift = new OculusRift();
oculusRift.init();
HMDInfo hdmInfo = oculusRift.getHMDInfo();
System.out.println(hdmInfo);
// while(oculusRift.isInitialized()){
//
// }
oculusRift.destroy();
}
}
But I get this error
Exception in thread "main" java.lang.UnsatisfiedLinkError: de.fruitfly.ovr.OculusRift._initSubsystem()Z
at de.fruitfly.ovr.OculusRift._initSubsystem(Native Method)
at de.fruitfly.ovr.OculusRift.init(OculusRift.java:82)
at ec.test.test3.Test.main(Test.java:21)
Java Result: 1
I created and included a Library based on:
JRift-0.2.5.1.jar
JRiftLibrary-0.2.5.1.jar
JRiftLibrary-0.2.5.1-natives-windows.jar
From here
What is missing?
Edit:
Forced by extracting JRiftLibrary64.dll and adding its path explicitly to the java path
System.loadLibrary("JRiftLibrary64");
It works.. why does not work on the other way?
Have you tried JOVR? https://github.com/jherico/jovr
Here a complete example: https://github.com/jherico/jocular-examples
This library is simple, very solid and compatible with the current Oculus Runtime 1.8
Regards
Related
This is my code and i have added the .dll to the place where Java_Home is. And i have this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: proiectP.JavatoC.getval(I)I at proiectP.JavatoC.getval(Native
Method) at proiectP.JavatoC.main(JavatoC.java:19)
public class JavatoC {
public native int getval(int b);
static {
System.loadLibrary("main");
}
public static void main(String[] args) {
try {
int a;
int b=3;
a= new JavatoC().getval(b);
System.out.println(a);
} catch(Exception e) {
System.out.println(e);
}
}
}
I also tried to write a= new proiectP.JavatoC().getval(b) as proiectP is the package. It doesn't work.
It seems library link not done right. There is a problem in the System.loadLibrary. Because it can't show the required method.
These are requirements for using a native code in Java, And I don't know which has not been observed :
First, make sure that the native file is correct, the getval method must be in that dll, exactly with the same specifications of name, input and output.
Second, it is exactly compiled for this use.
The last is in the right direction with the right name.
Somehow, if I create a new java project with an almost empty class, Java returns the following error message:
java.lang.ArrayIndexOutOfBoundsException: 0
at jxl.biff.drawing.PNGReader.main(PNGReader.java:141)
The jExcel api (jxl) is not included in the program and neither the .jar file.
The program code is as follows:
public class Main {
public static void main(String[] args) {
System.out.println("Good morning");
}
}
I don't think there are any problems in my java code since I ran the program properly in BluJ, but I use geany extensively instead. However, a strange problem occurred today while building the program in geany. I have defined the main method properly in my code, but despite my program got compiled without any errors, while running it after executing the program in geany I got this error:
Error: Main method not found in class Ter, please define the main method as: public static void main(String[] args) or a JavaFX
application class must extend javafx.application.Application
My program is:
public class Ter {
public static void main(String[] args) {
int scored=3;
int concede=5;
char result = (scored > concede) ? 'W':'L';
System.out.println(result);
}
}
Every time i run a hive query which has an OR condition from my java program, I get the following error,
Caused by: java.lang.ClassCastException: org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableStringObjectInspector cannot be cast to org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector
at org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPOr.initialize(GenericUDFOPOr.java:53)
at org.apache.hadoop.hive.ql.udf.generic.GenericUDF.initializeAndFoldConstants(GenericUDF.java:117)
at org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc.newInstance(ExprNodeGenericFuncDesc.java:232)
at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory$DefaultExprProcessor.getXpathOrFuncExprNodeDesc(TypeCheckProcFactory.java:958)
at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory$DefaultExprProcessor.process(TypeCheckProcFactory.java:1175)
at org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher.dispatch(DefaultRuleDispatcher.java:90)
at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.dispatchAndReturn(DefaultGraphWalker.java:94)
at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.dispatch(DefaultGraphWalker.java:78)
at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.walk(DefaultGraphWalker.java:132)
at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.startWalking(DefaultGraphWalker.java:109)
at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory.genExprNode(TypeCheckProcFactory.java:192)
at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory.genExprNode(TypeCheckProcFactory.java:145)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genAllExprNodeDesc(SemanticAnalyzer.java:10650)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genExprNodeDesc(SemanticAnalyzer.java:10606)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genExprNodeDesc(SemanticAnalyzer.java:10577)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genFilterPlan(SemanticAnalyzer.java:2736)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genFilterPlan(SemanticAnalyzer.java:2717)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genBodyPlan(SemanticAnalyzer.java:8972)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:9884)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:9777)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genOPTree(SemanticAnalyzer.java:10250)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10261)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10141)
at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:222)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:430)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:305)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1123)
at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:1110)
at org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:99)
... 26 more
But when i tried to run the following java program just to test the casting, it is cast successfully.
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableStringObjectInspector;
public class MyClass {
public static void main(String[] args) {
ObjectInspector[] arguments = new ObjectInspector[2];
BooleanObjectInspector boi0 = (BooleanObjectInspector) arguments[0];
BooleanObjectInspector boi1 = (BooleanObjectInspector) arguments[1];
System.out.println(boi1);
}
}
I have only one jar file which is hive-exec-5.5.4 in my classpath. So i dont see any jar conflicts. Any other solutions?
My Bad,
The Right end of the OR clause in the query did not have a condition after key. I have solved the issue.
I need to call Windows Color System functions from Java. Following this tutorial i tried to call DLL function using Java Native Access. All examples from this tutorial works fine. When i try to load and use Mscms.dll (one of the WCS libraries) that DLL seems to be loaded successfully, but i can not call any functions. List of functions is here.
I got a message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'GetColorDirectory'
What's wrong with my code? Could you help me please?
import com.sun.jna.Library;
import com.sun.jna.Native;
public class WCS_test {
public interface Mscms extends Library {
// http://msdn.microsoft.com/en-us/library/dd316928%28v=vs.85%29.aspx
boolean GetColorDirectory(String pMachineName, String[] pBuffer, int pdwSize);
}
private static Mscms mscms = (Mscms) Native.loadLibrary("C:/Windows/system32/Mscms.dll", Mscms.class);
public static void main(String[] args) {
if (mscms != null)
System.out.println("Library loaded\n");
else
System.err.println("Library loading error\n");
String[] pBuffer = new String[1024];
mscms.GetColorDirectory(null, pBuffer, pBuffer.length);
}
}
When you get a java.lang.UnsatisfiedLinkError that means that it could not find the function 'GetColorDirectory' inside of the Mscms.dll. Looking at the link from your source code http://msdn.microsoft.com/en-us/library/dd316928%28v=vs.85%29.aspx you should try the Unicode name GetColorDirectoryW.