Using JNA to restore window from taskbar on Linux Server

237 views
Skip to first unread message

Jeremie

unread,
Nov 13, 2013, 1:23:13 PM11/13/13
to jna-...@googlegroups.com

Hello,

 

I am programming using Java Web (Wicket) and would like in my web application to have a button that allows the user to restore a program (window) located in the taskbar.

 

I  have the name of the window, so I can retrieve it by name.

 

Here is my code:

 

HWND hwnd = User32.INSTANCE.FindWindow(null, "Window Title"); User32.INSTANCE.ShowWindow(hwnd, 9); User32.INSTANCE.SetForegroundWindow(hwnd); // bring to front

 

I added the libraries (jna.jar and jna-platform.jar) in my NetBeans project, and deployed that on my local Tomcat 8 server. It worked perfectly.

 

NOTE: Here are my development computer's specifications:

 

  1. Windows 8 Pro 64-bit Intel® Core™ i7-4770K CPU @ 3.50 GHz
  2. Java JDK/JRE 7u45

 

The problem was when I put my web application's war file on a development server.

 

The development server is a Linux (Ubuntu) OS version 3.5.0-17-generic with JVM version 1.7.0_25-b30 and OS architecture amd64.

 

When I tried running the web app on the Linux server, it kept telling me about missing libraries such as linux-x86-x64.jar.

 

Just briefly, a few questions:

 

  1. Is JNA also working with Linux and with the same flexibility as on Windows (I read about X11)?
  2. Is there anything special I should be aware when doing this?
  3. Is there any special or particular system library (.dll in Windows/.so in Linux) I should work with?

 

Would you please give me some hints on what parameters I must take into account if I deploy my application on a Linux server?

 

BTW, I installed the JNA library on the Linux server using the command line

($ sudo apt-get install libjna-java).

From <http://www.datastax.com/docs/1.0/install/install_jre#install-jre-deb>

 

Attached are logs from the Linux server's tomcat server.


Thanks,

Jeremie

logsJNAonLinuxServer.txt

Timothy Wall

unread,
Nov 13, 2013, 2:48:13 PM11/13/13
to jna-...@googlegroups.com
The first error you're seeing is because you've got an app trying to load JNA when another app has already loaded it. You can't load the same native library under two different apps in tomcat unless you load it in the tomcat container itself before the apps (so that the class loader + native library combination is shared among all apps).

Alternatively you could have each app load its own copy of the native library (JNA 4.0 allows for this, providing the context class loader for a given app accesses a unique version of the JNA share library).

The other error is that you're apparently trying to load your windows code (user32) on linux. Why would you expect that to work? Your logic in putting client-side native code onto a web server escapes me.
> --
> You received this message because you are subscribed to the Google Groups "Java Native Access" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> <logsJNAonLinuxServer.txt>

Reply all
Reply to author
Forward
0 new messages