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) {
MessageDialog.openInformation(
window.getShell(),
"Short
Path", new Hello().checkInsideFolder());
}
----------------------------------------------------------------------------------------------------------------------------------------------
package com.xyz.shortpath.actions;
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",
CKernel32.class);
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){
e.printStackTrace();
}
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);
// }
}
Regards
Haribabu.M
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.