Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] JNI problem with plug-in project

Did you set the java.library.path argument while running under Arguments tab in the Run configuration?

On Tue, Sep 7, 2010 at 12:58 PM, HariBabu M <HariBabu.M@xxxxxxxxxxxxxxx> wrote:

I am writing a JNI programme to call a windows api “GetShortPathNameA”.


When I am running this programme as standalone java programme, this works fine. However if I run this programme through eclipse plugin. This is giving a problem NoClassDefFoundError at CKernel32.INSTANCE.GetShortPathNameA(filePath, shortt, 256);


Even though the jars are in the class path for java project/plugin project. I am not sure how this will vary from normal java programme to plugin


Please help me what could be gone wrong here.




            public void run(IAction action) {



                                    "Short Path", new Hello().checkInsideFolder());






import com.sun.jna.Native;

import com.sun.jna.examples.win32.Kernel32;


public class Hello {


            public static interface CKernel32 extends Kernel32 {

                        CKernel32 INSTANCE = (CKernel32) Native.loadLibrary("kernel32",



                        int GetShortPathNameA(String LongName, byte[] ShortName, int BufferCount);




            public static String checkInsideFolder() {

                        String filePath = "C:\\Documents and Settings\\harib2\\Desktop\\swupdates.bmp";

                        String shortPath = null;

                        byte[] shortt = new byte[256];

                        int a = 0;

                        try {

                        a = CKernel32.INSTANCE.GetShortPathNameA(filePath, shortt, 256);

                        } catch (Exception e){



                        if (a != 0) {

                                    shortPath = Native.toString(shortt);

                                    return shortPath;

                        } else {

                                    return shortPath;



//          public static void main(String[] args) {

//                      String sample = checkInsideFolder();

//                      System.out.println(sample);

//          }





This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails.

platform-ui-dev mailing list

Back to the top