Eclipse JNI Help? [message #511058] |
Fri, 29 January 2010 11:29  |
Eclipse User |
|
|
|
Hi,
I have a simple file that looks like this:
package test;
package test;
public class Hello {
public native void sayHello();
static {
System.out.println("testing2");
System.loadLibrary("hello");
System.out.println("passed testing 2");
}
public static void main(String[] args) {
System.out.println("testing");
Hello h = new Hello();
h.sayHello();
}
}
I can run the class in command prompt with java -classpath C:\Docu...\CodeCount\src test.Hello and it prints "Hello World!"
However, when I try to run that from a view that I created, it failed (by calling the action).
class caction extends Action{
public caction(final String s){
super(s);
}
public void run(){
System.out.println("running");
IEditorPart ipart=(IEditorPart )getSite().getPage().getActiveEditor();
System.out.println(ipart.getClass().toString());
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
if(ipart.getClass().toString().equals("class org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor "))
{
System.out.println("java file");
}
System.out.println("???");
Hello test= new Hello();
System.out.println("passed");
showMessage("success");
}
}
terminal print-out:
running
class org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor
java file
???
testing2
I think it failed to load the library, since it never gets to passed testing 2. Can someone tell me how to fix this problem?
Any help would be appreciated.
Thanks,
MC
[Updated on: Fri, 29 January 2010 11:32] by Moderator
|
|
|
Re: Eclipse JNI Help? [message #511453 is a reply to message #511058] |
Mon, 01 February 2010 10:59  |
Eclipse User |
|
|
|
Hi,
I suggest you try post this question to a general Java newsgroup.
A quick scan on your posting and I suggest you to check if your hello
library exists. You can also try debug mode and set a break point a the
loadLibrary line to step thru the exection.
Eugene
"Mark Cheung" <iammark1237@yahoo.com> wrote in message
news:hjv2dc$fqb$1@build.eclipse.org...
> Hi,
> I have a simple file that looks like this:
>
> package test;
>
> public class Hello {
> public native void sayHello();
>
> static {
> System.out.println("testing2");
> System.loadLibrary("hello");
> }
> public static void main(String[] args) {
> System.out.println("testing");
> Hello h = new Hello();
> h.sayHello();
> }
>
> }
> I can run the class in command prompt with java -classpath
> C:\Docu...\CodeCount\src test.Hello and it prints "Hello World!"
>
> However, when I try to run that from a view that I created, it failed (by
> calling the action).
>
> class caction extends Action{
> public caction(final String s){
> super(s);
> }
> public void run(){
> System.out.println("running");
> IEditorPart
> ipart=(IEditorPart )getSite().getPage().getActiveEditor();
> System.out.println(ipart.getClass().toString());
>
> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
> if(ipart.getClass().toString().equals("class
> org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor "))
> {
> System.out.println("java file");
>
> }
> System.out.println("???");
> Hello test= new Hello();
>
> System.out.println("passed");
> showMessage("SLOC Computed");
> }
> }
> print-out:
> running
> class org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor
> java file
> ???
> testing2
>
> I think it failed to load the library, since it never gets to testing. Can
> someone tell me how to fix this problem?
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03818 seconds