B4J Library jxFunction native API access library

This library is an example of how you can access native API calls rather than being a complete solution in itself. This is because the library needs to be recompiled with the code added for the the API calls that you wish to make. The source is included in the archive so you could attempt this yourself with Eclipse or the Simple Library Compiler after reading the xFunction documentation included with the xFunction library download.

This library demonstrates Win32 API access, although there is a Linux version of the underlying xFunction library available. As useful examples this library implements the API calls Beep, MessageBeep and GetVersionExA.

The library requires xFunction. xFunction is a product of Excelsior, LLC http://www.excelsior-usa.com and has been placed in the public domain. It may be downloaded from http://www.excelsior-usa.com/xfunctiondl.html taking note of the conditions of use.

Read the comments in the xml for more information. If you don't have it get Object Browser to do so.
http://www.b4x.com/android/forum/threads/help-documentation-b4a-object-browser.25682/
 

Attachments

  • jxFunctionDemo1.0.zip
    8.4 KB · Views: 758

positrom2

Active Member
Licensed User
Longtime User
Great. (Looked it up: ) ingenious , more ingenious , most ingenious. The latter. Thank you.
 
Last edited:

KitCarlson

Active Member
Licensed User
Longtime User
I copied the xFunction related files as suggested in the sample documentation.

I encountered this link error:
java.lang.UnsatisfiedLinkError: C:\....\xFunction.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

My system is an intel Core i5 w7-64bit, Java SDK 1.7.0_45, jre7, and other B4J examples I have tried work. Any idea of what I am doing wrong?
 

positrom2

Active Member
Licensed User
Longtime User
Somewhere I found the recommendation to install both JDKs on a 64bit system. I did so. No problem with xFunction.
 

magoandroid

Member
Licensed User
Longtime User
Hi,
Check that xFunction.jar is in the additional libraries folder and a copy of xFunction.dll in your objects folder or on your Java classpath.

My system is an intel Core i5 w7-64bit.
With jdk-7u45-windows-i586, everything works (see png).

If I use jdk-7u45-windows-x64 I get this:
Program started.
main._appstart (java line: 59)
java.lang.UnsatisfiedLinkError: D:\A_ProveB4J\jxFunction\Objects\xFunction.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
...


Sorry for my English.
MAgo
 

Attachments

  • ixFunction.png
    ixFunction.png
    234.6 KB · Views: 600
  • ixFunction.png
    ixFunction.png
    234.6 KB · Views: 530

KitCarlson

Active Member
Licensed User
Longtime User
Thank you all for the replies, it is now working. I downloaded the x86, and re-configured the javac.exe path.
 

William Hunter

Active Member
Licensed User
Longtime User
I have added the jxFunction library to a B4J project in order to add the beep sounds. I found that while I could run and compile the project to a jar file, that jar file would not run as an executable. (I had been trying to wrap the jar into a windows exe using Launch4J, without success. This started me backtracking to see where the problem might be.)

I then turned to the jxFunctionDemo to see if the same result occurred there, and it does. The demo will run in B4J and compile to a jar file. But that jar file, as with the jar file created in my own project, will not run as an executable. It’s odd that I can run the code in B4J without a problem, and yet the executable jar file produced fails to run. I can’t see any configuration problems with my setup. Has anyone else had this problem? I need to sort out whether the problem rests with my setup or the library. Any help greatly appreciated.

I’m using Windows 7 Home Premium(32Bit), Version 6.1.7601, Service Pack 1, Build 7601.

Best regards
 

William Hunter

Active Member
Licensed User
Longtime User
Define "not run as an executable". Crash? Error message? Stack trace? Who knows?

The problem is not the library. If it fails silently try running it from a command prompt by invoking "java -jar <MyJarName>.jar" so you can see the log.
Thank you agraham, for your response. I ran the jar from a command prompt and logged this error - java.lang.UnsatisfiedLinkError: no xFunction in java.library.path. The problem is with my setup, and not the library. I’m having a problem in placing xFunction.dll in the correct location.

Under Environment Variables, Windows shows my CLASSPATH as being - .;C:\Program Files\Java\jre7\lib\ext\QTJava.zip. (The leading period and semicolon are there for some reason that I don’t understand. I’ve tried using the CLASSPATH with and without these two leading characters.)

1. For my first try I placed xFunction.dll in - C:\Program Files\Java\jre7\lib\ext. This didn’t work, and I received the error - no xFunction in java.library.path, as a B4J error.

2. I then moved xFunction.dll to the bin folder of my Java path.- C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe. I could then run and compile the project to a jar file, but that jar file failed silently on attempting to run.

3. I have now moved xFunction.dll to the Objects folder of my project and that works fine, except if you distribute your exe you must include xFunction.dll in the package. I need to know where to place xFunction.dll so that it is in my CLASSPATH.

I’ve done quite a bit of searching the Internet to try and resolve this issue. While I find a lot of technical info re Java, I haven’t found an explanation of where a dll of this nature should be placed. Does my CLASSPATH require further configuration to include a specific pointer to xFunction.dll? Any help to clarify this for me would be greatly appreciated.

Best regards
 

William Hunter

Active Member
Licensed User
Longtime User
I think it should just work if you put it with the jar.
Thank you again agraham, for your response. I now have xFunction.dll in the Objects folder, along with the jar file. This works fine, but I had thought that if xFunction.dll was in my CLASSPATH it would be embedded in the executable jar. This may not be the case.

I haven't seen a good answer for this anywhere. Is it possible to embed a pre-existing DLL into a compiled executable jar, so that you only have one file to distribute once it is wrapped to a Windows exe? If this is possible, how would one go about doing it?

Best regards

Edit: For anyone interested in this subject, see Erel's post at the link below:

http://www.b4x.com/android/forum/threads/running-a-dll.35546/#post-208477
 
Last edited:

kris_audi

Member
Licensed User
Longtime User
Hi,
When I press the button Beep I hear the sound and the message appears:

Major Version:5
Minor Version:1
Build Number: 2600
Platform Id: 2
CSD Version: Dodatek Service Pack 3

and no sound is near pressing remaining buttons.
 

Attachments

  • capture_18122013_114944.jpg
    capture_18122013_114944.jpg
    353.8 KB · Views: 429

kris_audi

Member
Licensed User
Longtime User
When I press the buttons I hear the sound but when I press the button Beep the message appears far.
 

kris_audi

Member
Licensed User
Longtime User
I turned on the sounds in Control Panel and it is well now but when I press the button Beep the message appears far.
 

kris_audi

Member
Licensed User
Longtime User
I apologize but I did not notice that the above mentioned message appeared correctly.

Msgbox.Show(Win32.GetVersionExA, "")

Thank you agraham.
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Andrew,
When using the xFunction library in your programs, ensure that the
java.library.path property contains a path to the directory where
xFunction.so resides.

In Win8, I must copy xfunction.dll in the objects folder. In Linux,I must copy xfunction.so in the objects folder instead of xfunction.dll ,It 's right? (I'm not understand English)
 
Top