Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Icon when application runs in WSL environment #88

Closed
bardware opened this issue Jul 17, 2018 · 12 comments
Closed

Show Icon when application runs in WSL environment #88

bardware opened this issue Jul 17, 2018 · 12 comments

Comments

@bardware
Copy link

Hi,

I'm not a JAVA devloper myself. However, I'm using a JAVA console application that uses your library to display a TaskTray icon. I'd love to use Ubuntu on windows (WSL) rather than cmd to start the software. Difference when using this application in the WSL environment is the missing TrayIcon.
Can your lib somehow detect it's running Ubuntu on Windows and use the taskbar?
Do you have an idea?

@dorkbox
Copy link
Owner

dorkbox commented Jul 19, 2018

It's possible to detect if it's running Ubuntu on Windows -- that's a good idea, and I didn't even think about that.

I have some ideas on what to do... I'm swamped working on so many other things right now, it might be a while to do this, but it will happen.

@tresf
Copy link

tresf commented Jul 19, 2018

Is this even possible? Last I knew, WSL couldn't run a GUI without a dedicated X server. Am I missing something?

@dorkbox
Copy link
Owner

dorkbox commented Jul 19, 2018

Not missing anything -- possible to detect, but not sure if possible to show the icon ;)

@tresf
Copy link

tresf commented Jul 19, 2018

I just tried, and WSL says that it can't find an X11 display server.

You can -- however -- run it with java.exe. This is an interoperability feature.

For example, this is possible through WSL...

Linux version:

java -jar /mnt/c/my-app.jar

Windows version:

java.exe -jar C:\my-app.jar

This has the advantage of being able to stay inside the WSL terminal window, but execute the Windows version of the app.

@dorkbox I'm not sure you can do better than this until the UI components are directly accessible, which is not really your bug to sort. :)

@dorkbox
Copy link
Owner

dorkbox commented Jul 19, 2018

:D thanks for figuring this out @tresf! I'll leave this issue open (and even include this somehow in the readme) so if anyone else has this question, there is an answer.

@tresf
Copy link

tresf commented Jul 19, 2018

Here's a real-world use-case using a Java text-editor "jEdit"...

WSL using java.exe (notice the system tray icon)

 java.exe -jar C:/Program\ Files/jEdit/jedit.jar

screen shot 2018-07-18 at 10 53 32 pm

WSL using java (complains no X display server and aborts)

java -jar /mnt/c/Program\ Files/jEdit/jedit.jar

screen shot 2018-07-18 at 10 55 07 pm

@bardware
Copy link
Author

Thnaks for caring. I have not tried myself by now but I understand there are X servers for Windows available. Would that work?

@dorkbox
Copy link
Owner

dorkbox commented Jul 19, 2018

@tresf
Copy link

tresf commented Jul 19, 2018

I understand there are X servers for Windows available. Would that work?

I've used XMing on Windows for years and it works OK, but to do as you're describing the XMing source code would have to be modified to work with the native system tray. I still don't see this as a problem that can be solved inside a Java library. :)

@bardware
Copy link
Author

don't see this as a problem that can be solved inside a Java library

Any input helps! Thanks alot for caring.

I installed XMING and ended up with this message:

Unable to create tray type: '_SwingTray'
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at dorkbox.systemTray.SystemTray$1.run(SystemTray.java:965)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.RuntimeException: System Tray is not supported in this configuration! Please write an issue and include your OS type and configuration
        at dorkbox.systemTray.ui.swing._SwingTray.<init>(_SwingTray.java:60)
        ... 19 more
system tray hook failed
java.lang.NullPointerException
        at runwar.tray.Tray.addMenuItems(Tray.java:185)
        at runwar.tray.Tray.instantiateMenu(Tray.java:125)
        at runwar.tray.Tray.hookTray(Tray.java:107)
        at runwar.Server.startServer(Server.java:685)
        at runwar.Start.main(Start.java:127)

Please feel free to close this issue.

@dorkbox
Copy link
Owner

dorkbox commented Aug 18, 2018

New release 3.15, now includes a windows native tray icon implementation - which might solve the issue with the SwingTray type.

edit: clarity on which issue it might solve.

@dorkbox
Copy link
Owner

dorkbox commented Nov 11, 2018

I've now added comments to the readme regarding this issue. @tresf, thank you for your help/feedback with this.

@dorkbox dorkbox closed this as completed Nov 11, 2018
Repository owner deleted a comment from vaibhav112212 Jul 30, 2022
Repository owner deleted a comment from vaibhav112212 Jul 30, 2022
Repository owner deleted a comment from vaibhav112212 Jul 30, 2022
Repository owner deleted a comment from vaibhav112212 Jul 30, 2022
Repository owner deleted a comment from vaibhav112212 Jul 30, 2022
Repository owner deleted a comment from vaibhav112212 Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants