2 messages in net.java.dev.jna.usersRe: [jna-users] JNA beginner: Problem...
FromSent OnAttachments
aumasterApr 4, 2008 5:25 am 
Timothy WallApr 4, 2008 6:18 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] JNA beginner: Problem to get "FileUtils" sample running - Please help...Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Apr 4, 2008 6:18:27 am
List:net.java.dev.jna.users

On Apr 4, 2008, at 8:25 AM, aumaster wrote:

Hi,

sorry, i'm just beginning using JNA and i have a problem to get the "FileInfo" sample running...

1.) I downloaded the JNA sources from svn

2.) I made a new project with "IntelliJ" for testing the FileInfo sample

3.) I copied following files to the project to run the sample (and removed line "package com.sun.jna.examples.win32;" in source files) - FileUtils.java - Shell32.java - W32API.java - W32Errors.java - jna.jar

4.) I created a start file to call FileUtils named "FileUtilsTest.java" with the following content:

public static void main(String[] args) { FileUtils fu = FileUtils.getInstance(); File[] fileArr = new File[] { new File("trashTest.fil") }; fu.moveToTrash(fileArr); }

5.) Trying to compile gives following error: Cannot resolve symbol 'SHFILEOPSTRUCT'

6.) So i rearranged "Shell32.java" that the compiler finds the Shell32.java inner class SHFILEOPSTRUCT

7.) Compiling is ok, but now there's following error:

Exception in thread "main" java.lang.Error: Exception reading field 'hwnd' in class SHFILEOPSTRUCT: java.lang.IllegalAccessException: Class com.sun.jna.Structure can not access a member of class SHFILEOPSTRUCT with modifiers "public"

Structures must have a public no-args constructor. If the class is an inner class, it must be declared static.

If the class itself has any access less than "public", then the Structure base class won't be able to read/write fields.

Is there anyone out there who can submit a working example for the "FileUtils" or can give a hint what's wrong?

You might have better luck letting your IDE do the refactoring for you :).