This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help in javah

 
Vishal Gautam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am a newbee to java and jni

I have following code


package com.vishal.practice;
import java.io.PrintWriter;
public class NativeDemo
{
int i;
public static void main(String[] args)
{
NativeDemo ob = new NativeDemo();

ob.i = 10;
PrintWriter pw = new PrintWriter(System.out);
pw.write("Before: " + ob.i);
ob.test();
pw.write("After: " + ob.i);
}

public native void test();

static
{
System.loadLibrary("NativeDemo");
}
}



I have compiled the code to build .class file

when I try to execute the following command

javah -jni com.vishal.practice NativeDemo

I get the following error

Error: Class com.vishal.practice.NativeDemo could not be found.

Not Sure what the reason is.

Please Help

Regards
Vishal
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


[b]I am a newbee to java and jni</b>

I think that jni is not a beginner topic. However, I wonder if your problem is in the way you are using the command rather than with your code. What if you put a dot before NativeDemo? Like this:

javah -jni com.vishal.practice.NativeDemo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic