Skip to content

Show Icon when application runs in WSL environment #88

Closed

Description

@bardware

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?

Activity

  1. dorkbox commented on Jul 19, 2018

    @dorkbox
    Owner

    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.

  2. tresf commented on Jul 19, 2018

    @tresf

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

  3. dorkbox commented on Jul 19, 2018

    @dorkbox
    Owner

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

  4. tresf commented on Jul 19, 2018

    @tresf

    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. :)

  5. dorkbox commented on Jul 19, 2018

    @dorkbox
    Owner

    :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.

  6. tresf commented on Jul 19, 2018

    @tresf

    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

  7. bardware commented on Jul 19, 2018

    @bardware
    Author

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

  8. dorkbox commented on Jul 19, 2018

    @dorkbox
    Owner
  9. tresf commented on Jul 19, 2018

    @tresf

    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. :)

  10. bardware commented on Jul 19, 2018

    @bardware
    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.

  11. dorkbox commented on Aug 18, 2018

    @dorkbox
    Owner

    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.

  12. dorkbox commented on Nov 11, 2018

    @dorkbox
    Owner

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

  13. Repository owner deleted a comment from vaibhav112212 on Jul 30, 2022
  14. Repository owner deleted a comment from vaibhav112212 on Jul 30, 2022
  15. Repository owner deleted a comment from vaibhav112212 on Jul 30, 2022
  16. Repository owner deleted a comment from vaibhav112212 on Jul 30, 2022
  17. Repository owner deleted a comment from vaibhav112212 on Jul 30, 2022
  18. Repository owner deleted a comment from vaibhav112212 on Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions