We are using jni.h but its getting errors, please check it this

We are using jni.h but its getting errors, please check it this
Calling from a .dll using Java and JNI - by Borland Developer Support Staff
Abstract:Basic JNI example: making a Win32 API call
Making Native Windows API calls from within a Java Application
One of the main points of Java is to be completely platform independent. However, sometimes it will occur that the developer of an
application will know that his or her application is only going to be run on a specific platform, for example, Win32.
NOTE: This example assumes that you are using JDK 1.2 or later.
Below are the steps for writing a Java application that makes a Win32 API call. The application generates a Swing Jframe and makes it
system modal, or gives it the �Always On Top� functionality, similar to that of the Windows NT Task Manager.
Steps to follow:
1. Write the Java code for the application
2. Run javah.exe on your .class file to generate a C header file
3. write the implementation of your native methods
4. create the shared library
5. run the application
1. Write the Java code for the application
import java.awt.*;
import sun.awt.*;
import sun.awt.windows.*;
import javax.swing.*;
import java.awt.event.*;
public class Frame1 extends JFrame {
int windowHWND = 0;
JButton jButton1 = new JButton();
public Frame1() {
//windowHWND = this.getHwnd();
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
public int getHwnd() {
DrawingSurfaceInfo w = (DrawingSurfaceInfo) ((DrawingSurface) getPeer()).getDrawingSurfaceInfo();
w.lock();
WDrawingSurfaceInfo win32 = (WDrawingSurfaceInfo) w;
int hwnd = win32.getHWnd();
w.unlock();
return hwnd;
static {
System.loadLibrary("windowOnTop");
public static native void WindowAlwaysOnTop(int hwnd, boolean flag);
public static void main(String[] args) {
Frame1 frame11 = new Frame1();
frame11.setSize(400,400);
frame11.setVisible(true);
private void jbInit() throws Exception {
jButton1.setText("jButton1");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(WindowEvent e) {
this_windowOpened(e);
public void windowClosing(WindowEvent e) {
this_windowClosing(e);
this.getContentPane().add(jButton1, BorderLayout.NORTH);
void this_windowOpened(WindowEvent e) {
windowHWND = this.getHwnd();
System.out.println("the value is: " + this.getHwnd());
this.WindowAlwaysOnTop(windowHWND, true);
void this_windowClosing(WindowEvent e) {
System.exit(0);
Once the code is written, compile it with Jbuilder or the command line javac.exe tool which will result in a generated .class file. You will use
this .class file in the next step.
2. Run javah.exe on your .class file to generate a C header file
The following line represents the basic syntax for running javah.exe:
javah Frame1
where Frame1 is the name of the argument class.
When you run javah.exe, it will generate a header file by the same name as your implementation but with a .h file extension. For this
example the .h file that was generated from the above Java code will be emitted being that it is quite large.
NOTE: Make sure that when you run javah.exe, it is the javah.exe that came with the same JDK that you will be compiling with as there may
be some issues with using a version of javah.exe that is different from that of the JDK you are using to compile.
3. write the implementation of your native methods
Now that you have your Java source and your C header file, it is time to write the implementation of your native methods.
Following is the C code that corresponds to the native methods declared in the Java code listed in step 1:
#include "jni.h"
#include "Frame1.h"
#include <stdio.h>
#include<windows.h>
JNIEXPORT void JNICALL Java_Frame1_WindowAlwaysOnTop(JNIEnv *env, jclass obj, jint hwnd, jboolean flag)
if (flag)
SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
else
SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
return;
You will notice several things: one is that the function signature has �Java_Frame1_� preceeding the name of the function. If there was a
package statement in the Java source, it would appear after ��Frame1_� in the function signature.
Second, you will notice the #include �jni.h�. Normally this would be #include<jni.h>, depending on how you have your libraries set up within
your C compiler.
4. create the shared library
Now you are ready to create the shared library. Using your C compiler, create a .dll file with the code from the C implementation file. Refer
to the doccumentation of the C compiler for details on creating a .dll file.
For those interested in using Borland C++ Builder:
If you have got it installed, you could use Borland C++ Builder 3 or C++ Builder 4 to create your DLL file. If this is the case, you would use
File | New... | DLL C++ Builder will then generate some code for you, and you will just need to add your implementation code to the code
which was generated.
Remember in the Java code in step one there is a line:
static {
System.loadLibrary("windowOnTop");
�windowOnTop� is the name of the .dll file. You can name it whatever you want, just make sure that you specify the appropriate name when
loading the library.
5. run the application
Finally you are ready to run the application. From the command line use java.exe and as the argument specify the name of the class that
you compiled in step one. Once the system loads your DLL, the window that the VM creates should mimic the �Always On Top�
functionality.
We are getting errors like this
�Compiling JNI.H:
Error JNI_MD.H 23: , expected
Error JNI.H 115: Declaration missing
Error JNI.H 200: ) expected
Error JNI.H 202: ) expected

#include "jni.h"
#include "Frame1.h"
#include <stdio.h>
#include<windows.h>
JNIEXPORT void JNICALL Java_Frame1_WindowAlwaysOnTop(JNIEnv *env, jclass obj, jint hwnd, jboolean flag)
if (flag)
SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
else
SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
return;
We are getting errors like this
�Compiling JNI.H:
Error JNI_MD.H 23: , expected
Error JNI.H 115: Declaration missing
Error JNI.H 200: ) expected
Error JNI.H 202: ) expected

Similar Messages

  • I am using 4K Footages for editing in Premiere pro CC 2014, but its getting crash in between at every 15 to 20 mins. Kindly suggest how can it be solved, does any plugins or settings needed to edit 4K footages? Also would like to mention that footages fra

    I am using 4K Footages for editing in Premiere pro CC 2014, but its getting crash in between at every 15 to 20 mins. Kindly suggest how can it be solved, does any plugins or settings needed to edit 4K footages? Also would like to mention that footages frame rates are 29.97 and i have set timeline to 25 FPS is requirement by client. kindly revert. Thanks

    Thanks Richarad ..It has solved the problem but still crashes some times .As the programme has the break (bumper)after every five minutes ,i hope it will not compress bumper time too after export.

  • I'm using iphone 5 but its camera is not properly working. all the images i'm clicking are of dimension 600X800 and the size of the image is just 60-70 kb. now please tell me how to increase the dimension of images and its size.

    i'm using iphone 5 but its camera is not properly working. all the images i'm clicking are of dimension 600X800 and the size of the image is just 60-70 kb. now please tell me how to increase the dimension of images and its size.

    ''rojere [[#question-1055991|said]]''
    <blockquote>
    i try to keep my thumb palms off the mouse pad when i am typing but every now and then my screen resizes larger or smaller until i take my left palm off the keyboard base its only when my left palm is resting on the base next to the touch pad. i type pretty fast so it gets annoying and yes it also jumps screens or reverts back to previous message and i have to choose ctrl z to undo and get back to my message i was typing... it also switches tabs on me as well... not sure why my palm being on the left of the keypad on the base should effect anything but it does after a while. and i have to stop what i am doing...and go to the firefox menu and change the screen size back down to 100% sometimes it goes up to 200-300 other times it goes down to 70-80% i find it annoying i i wish there was a way to turn off the screen resize in the setup panel. if its just left to be 100% i am happy with that... i don't need it to be bigger or smaller... there should be a way to LOCK it down... i understand that there are people out there with eye problems and needs to have the screen size increase using the + or - but there should be a lock so it just stays no matter what is happening on my keypad or touch pad or base of the pad... that screen size will not increase or decrease. unless i turn off the lock... perhaps this is something they can implement in the next version or do a quick update of the browser
    </blockquote>
    sorry that is all greek to me thanks for attempting to explain what you were trying to explain sorry i just not tech person to be able to understand or where to begin ... have good day and thanks for again trying

  • My os x mavericks got crashed accidentely while installing the windows 8 and I am trying to reinstall using recovery console, but its take very long time and forcing me to download OS X 8 from internet, is there any where can I get offline download of OS.

    My os x mavericks got crashed accidentely while installing the windows 8 and I am trying to reinstall using recovery console, but its take very long time and forcing me to download OS X mountain lion from internet, is there any where can I get offline download of OS file where I can install directely OS X Mavericks.

    Hi, original poster here. I did not realize this would generate more discussion so I never checked back. I still had my warranty, so I took it to the store and got it repaired. The original problem I had was a screen with this icon flashing when I attempted to boot it up:
    When I took it to the store, they told me that my computer was unable to communicate with the hard drive. I had this same problem three times in two months where this screen reappeared. Each time I went back to the store and they said the cause was different, but they were all hardware issues that physically made it impossible to communicate with the hard drive. After the third time, they simply replaced my laptop and I haven't had the same problem.
    So in short: The reason you can't reinstall or move anything when you encounter this screen appears to be because nothing can communicate with the hard drive in the first place. You can't reach the disk or anything on it. So I don't believe it's possible to do anything besides take it to a physical store and have it fixed.

  • I know you can't "turn off" tv but its getting hot in standby..

    Hi
    I know you can't "turn off" tv but its getting hot in standby, I havent used it all day, and the top is still really warm. I know this is the heat sink, but why is it getting so hot when in standby and doing nothing, for many hours?
    To turn off I realise will have to switch off at mains. Is this recommended? when should I do it? when not syncing and in standby?
    I'm a little worried by how hot it is, when never used for about 48 hours and in standby
    cheers

    ........ leaving it on 24/7 doesnt cost that mch though does it?
    All depends on how much your electricity costs, at 10 p/c per kilowatt/hour, your tv using around 18 W in stand-by will cost you about 30 1/4 p/c a week.
    If cost is a factor for you then consider switching it off overnight, don't however worry too much about the heat. It may appear to run hot because of its unusual heat dissipation, however if you were to place your hand on the heat sync surrounding your cpu on your mac/pc, you'd likely realise comparatively the tv isn't excessively warm. (The CPU's in my mac are currently running at 44-56 C for example)
    I don't particularly see much wrong in turning the unit off from time to time, (although I'm not sure I like the idea of not knowing if the HDD is writing at the time) assuming it isn't excessive. Excessive switching is not good for most devices since strain on mechanical parts and stress caused to electrical components due to large temperature variations can lead to early failure.

  • My iphone is not charging or showing in my computer. but its getting charged via wall apple charger.. Not able to connect with itunes.. please help.... :(

    My iphone is not charging or showing in my computer. but its getting charged via wall apple charger.. Not able to connect with itunes.. please help....

    No it doesn't. Sometimes it make a sound that it should when connecting but that is it. Never actually charges or syncs. And it is a brand new cord.

  • Im trying to buy a song from a album but i get error that it is no longer available. The other songs is working and its a new album. I typer in the wrong password on this song. Could that be the issue?

    Im trying to buy a song from a album but i get error that it is no longer available. The other songs is working and its a new album. I typer in the wrong password on this song. Could that be the issue?

    Never rely upon the iTunes Store to always have your purchases.  Always keep a copy of everything safe on a backup drive at home.
    "After you download your purchases, back up your iTunes library. Previous purchases may be unavailable if they've been refunded or aren't on the iTunes Store." - http://support.apple.com/kb/ht2519

  • Im trying to use my messaging, but its telling me that my password is wrong? What should I do?

    Im trying to use my messaging, but its telling me that my password is wrong...what should i do?

    Unfortunately, when I turned on my mba and tried my internet connection on wifi with my airport express this morning... it no longer worked, as a password (WEP) is required !!! And there is no password on a airport express (as far as I know). and I didn't set any paswword !!!!
    Regarding iPhone and airport I didn't configure any security in order to make it simple for the beginning... so I stil don't understand why a password is required...
    I'm very disapointed as I thought that mac devices were plug and play and not dedicated to IT expert.
    Thank you for your help.

  • We have two company user,till now there are using same URL.but they wanted to access particular URL to related company user in single server

    Hi Experts,
    We have two company user,till now there are using same URL.but they wanted to access particular URL to related company user in single server.
    As per my knowledge ,it is possible through create new aliases with different URLs in network.
    But i dont how to create. Please help on this.
    Thanks in advance.
    Regards,
    Prasad

    Hi Prasad,
    Please explain in clear english as to what is your requirement. I got lost after "two company user" . I suppose it means there are users from two separate company: A and B. They were using same portal till now: http://commonportal:50000/irj/portal.
    Now they need different urls - specific for each company say companyAportal.com and companyBportal.com. But still the same old common portal in the end.
    If that's your requirement please search the forum with correct terms, else "Google".
    Thanks,

  • Im trying to download itunes 10.5 but keep getting error message that says: There is a problem with this Windows Installer package. A problem run as part of the setup did not finish as expected. Contact your support personnel or package vendor.

    im trying to download itunes 10.5 but keep getting error message that says: There is a problem with this Windows Installer package. A problem run as part of the setup did not finish as expected. Contact your support personnel or package vendor. I am using windows XP 32 bit, all the other computers in my house downloaded just fine, no problems, however this is the computer my iphone is set up to, ive tried doing a virus scan, windows update, downloading other things, updating everything possible, everything works fine, its just itunes that wont download, anyone have any other ideas?

    Yes, I had found a similar solution also.  I'm running XP Pro, SP3.  I went Control Panels/ Add-Remove programmes/apple software update/ change/ repair.  Then run the 10.5 exe.
    While the programme updated from version 8 of iTunes, my new iTunes is now a mess.  Not all of my music was in the same folder previously but it all showed up on iTunes.  Now many albums have been left out, some have only a few tracks and some have two copies of some tracks as well as having other tracks missing.  I haven't begun to work on that.

  • HT201210 I have an old i phone 3G and do not know the password for it. trying to restore it from itunes but keep getting error code 1015, any help on how to get passed this please?

    I have an old i phone 3G and do not know the password for it. trying to restore it from itunes so my daughter can use it as an ipod but keep getting error code 1015, any help on how to get passed this please?

    Hi ratcat14!
    I have an article that can help you troubleshoot this issue:
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/ts3694
    Check for hardware issues
    Try to restore your iOS device two more times while connected with a cable, computer, and network you know are good. Also, confirm your security software and settings are allowing communication between your device and update servers. If you still see the alert when you update or restore, contact Apple support.
    Common errors: 1, 10-47, 1002, 1011, 1012, 1014, 1000-1020.
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

  • TS3694 i have tried to restore my iphone but keep getting error 1015 any suggestions

    i have tried to restore my iphone but keep getting error 1015 any suggestion

    Error 1015: This error is typically caused by attempts to downgrade the iPhone, iPad, or iPod touch's software. This can occur when you attempt to restore using an older .ipsw file. Downgrading to a previous version is not supported. To resolve this issue, attempt to restore with the latest iPhone, iPad, or iPod touch software available from Apple. This error can also occur when an unauthorized modification of the iOS has occurred and you are now trying to restore to an authorized, default state.

  • I have 2 apple ID one for Egypt and other for USA , now I try to update the software but I get a message said that this software download with other ID, then I logout and sign with second ID but i got the same message again ... Now I can not sign in more

    I have 2 apple ID one for Egypt and other for USA , now I try to update the software but I get a message said that this software download with other ID, then I logout and sign with second ID but i got the same message again ... Now I can not sign in more
    Any solution ?
    I'm using iOS 6.1.2 IPad 3
    Regards

    I have also noticed the same "problem".  I do not fully understand the impact of using the same ID on multiple computers and devices if I want to keep them all in sync.

  • Tried to update ITunes, but keep getting error: Service "Apple Mobile Device" failed to start. Verify that you have sufficient privileges to start system services". How do I get my ITunes back?

    Tried to update ITunes, but keep getting error: Service "Apple Mobile Device failed to start.  Verify that you have sufficient privileges to start system services."
    So how do I get my ITunes back? 

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (if this won't uninstall move on to the next item)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
    Please note:
    Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
    HT1925: Removing and Reinstalling iTunes for Windows XP
    HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    tt2

  • Hi, i just updated my iphone 3gs to iso5 now it will not activate ive ''try again'' alot but not getting anywere please help!!

    hi, i just updated my iphone 3gs to iso5 now it will not activate ive pressed ''try again'' alot but not getting anywere please help! i need my phone for work not had it too long and really annoyed lol thanks,

    Sorry, but Apple does not provide a downgrade path for iOS.
    Because downgrading is unsupported by Apple we cannot discuss it on these forums, but you can use Google to find information on how to install an older version of iOS on any device.
    Note that you will void the warranty and loose official support by Apple.
    Feel free to let Apple know at http://www.apple.com/feedback
    Anyway, give a try resetting all your settings:
    Settings > General > Reset > Reset All Settings

Maybe you are looking for

  • Can not see my SMS in inbox on my T700, please help

    Hello, Since a short time, I can not see / access incoming SMS in the inbox of my T700. I can only open them directly when thery arrive from the desktop. Please help. Thank You Gerold

  • Help needed with a small XCode project...

    So I probably have found a way to disable command-tab app switching by updating the PullTab APE module to work with Leopard. I just need someone who knows it's way around XCode. I've been in contact with the author of PullTab, and he's confirmed that

  • How can I delete Z.SAPB18.8_MyPO object from B1iSN 8.8

    Dear All, I have created only one object type (apart from the B1iSN default one) Ex: For the Purchase Order object (LocalObjectId = 22) I defined only one B1iSN object type. but I have the same error message "Sender SysId, Sender ObjectType or Sender

  • Most recent jar file

    What is the difference between the mail-1.4.jar and the javamail.jar file and various other flavors I find out there? Which is the most recent, and which should I be using if still back on jdk 1.5?

  • Tools for running process flows and mappings

    The operations/production area is responsible for running process flows and mappings in a day by day base. As developer, I need to implement a solution that allow them run these artifacts. For this purpose, is there any tool apart from Control Center