Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Permenant System Tray

  1. #1
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Permenant System Tray

    I have created a program for a icon in the System Tray in elipse, I have got it to work though was wondering, would I need to constantly keep the eclipse program running for the icon to stay permanently in the System Tray?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Permenant System Tray

    would I need to constantly keep the eclipse program running
    No. eclipse is a fancy editor (an IDE) used to create java programs. Once the program has been created there is no need for eclipse. The program can be executed using the java command.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    keepStriving (December 9th, 2013)

  4. #3
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Re: Permenant System Tray

    When I stop the eclipse program, the icon disappears from the system tray. Should I run it with command line instead?

    --- Update ---

    When I stop the eclipse program, the icon disappears from the system tray. Should I run it with command line instead?

    I am using Windows.

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Permenant System Tray

    There are many ways to execute a java program. All require that the java command get the name of the class to be executed.
    One way is to create a jar file with the classes and double click it.
    Another is to create a batch file and double click it.
    If you don't understand my answer, don't ignore it, ask a question.

  6. The Following User Says Thank You to Norm For This Useful Post:

    keepStriving (December 9th, 2013)

  7. #5
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Re: Permenant System Tray

    I have converted my project into a JAR file which is on my desktop, how would I run a specific class from the JAR file?

    --- Update ---

    Double clicking the JAR file does not do anything.

  8. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Permenant System Tray

    The jar file needs to contain a manifest file that tells the java command what class it is supposed to execute.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #7
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Re: Permenant System Tray

    Thank you, I have done that, the icon is there and the program Is running, I was wondering would this mean that the program is constantly running which would affect CPU and how would I go about stopping the program for the system tray.

  10. #8
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Permenant System Tray

    You launched the program by double-clicking on the executable jar, yes it is loaded and running. That does not necessarily mean it is actually doing anything, that would depend on the specific program. You could stop the program by right clicking on the icon and closing it or with the task manager or restarting the computer etc but the best way would be to include some interface that can be used to tell the program to close itself, perhaps a window (even a small one with one word "Exit").

  11. The Following User Says Thank You to jps For This Useful Post:

    keepStriving (December 9th, 2013)

  12. #9
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Re: Permenant System Tray

    I have an EXIT MenuItem, I suppose I need to give it proper functionality.

    The system tray icon initiates a GUI which when I quit removes the system tray also, how would I get around this so when the GUI is exited the icon stays and then I will add a separate action listener for the icon so it can gracefully exit.

    --- Update ---

    I have figured this is because of the EXIT_ON_CLOSE operation when x is pressed, I have separate buttons which dispose of the frame instead and they leave the frame intact, is there any way I can get the default close operation of frame to dispose() instead of EXIT_ON_CLOSE or is there no way around this?

  13. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Permenant System Tray

    Read the API doc for the class to see what other options are available.
    If you don't understand my answer, don't ignore it, ask a question.

  14. The Following User Says Thank You to Norm For This Useful Post:

    keepStriving (December 10th, 2013)

Similar Threads

  1. ATM SYSTEM
    By kevinmontano41 in forum Member Introductions
    Replies: 1
    Last Post: October 16th, 2013, 06:40 AM
  2. System Tray
    By kaviri in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 7th, 2013, 01:49 PM
  3. system tray problems
    By laurence000 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 16th, 2013, 05:11 AM
  4. Creating System Tray Icon WinXP
    By domezone in forum Java Theory & Questions
    Replies: 4
    Last Post: May 15th, 2012, 02:29 AM
  5. Need an operating system
    By boardinggamer in forum Computer Support
    Replies: 10
    Last Post: April 10th, 2012, 09:20 AM