10 Replies Latest reply: Sep 27, 2013 7:25 AM by Sciuriware
Sciuriware Level 1 Level 1 (0 points)

Hello,

I wrote some JAVA applications and I would like to put them in -

- and start them from - the dock.

These applications were built into .jar files.

I can start them from Finder which tells me that there is some .jar starter utility.

;JOOP!


MacBook Pro with Retina display, OS X Mountain Lion (10.8.2)
  • 1. Re: Is there a way to start a JAVA program from the dock?
    Topher Kessler Level 6 Level 6 (9,340 points)

    You can often launch the jar file directly, and can drag it to the Dock and simply click it. If you need to use a specific terminal command to launch the jar file (ie, to set specific flags and environmental variables), then you can create an automator "Application" workflow and use the "Run Shell Script" action to do so. You can then save this workflow as an application and place it in the Dock or otherwise directly launch it.

  • 2. Re: Is there a way to start a JAVA program from the dock?
    Sciuriware Level 1 Level 1 (0 points)

    Indeed I can just open such a .jar file in Finder and the application runs.

    Then I set the dock icon for: KEEP IN DOCK.

    Then I stop the application .....

    ..... but: when I click the dock icon again a Terminal starts

    with only the Java command without the .jar argument

    (so the command comp-laints about: "no argument").

     

    Do you know where the dock icon is administered,

    because I have the feeling that when I can edit the command line in there

    I can solve almost any problem.

    ;JOOP!

  • 3. Re: Is there a way to start a JAVA program from the dock?
    andyBall_uk Level 7 Level 7 (20,320 points)

    What happens if you drag the .jar file to the dock, and then click on it ?

  • 4. Re: Is there a way to start a JAVA program from the dock?
    Barney-15E Level 8 Level 8 (35,280 points)

    Can you just drag the .jar file to the Dock?

     

    However, I really think you should just package it up as Topher suggested.

    .jar files are meant to run from the command line. If you want it to act like a normal application, you need to wrap it up inside some type of wrapper. Besides Automator, there is Platypus: http://sveinbjorn.org/platypus. I'm not sure if it can wrap up java, though. A bit of overkill, i guess.

  • 5. Re: Is there a way to start a JAVA program from the dock?
    Sciuriware Level 1 Level 1 (0 points)

    When I drag the .jar from the Desktop (directory) to the dock ... it flies back like a released bird.

    The same when I drag it from a file manager.

     

    I just came from MSWindows XP and 7; there I managed to put my application

    in the Quick Launch section (for my purpose almost the same situation).

    Also I noticed that Eclipse (workbench) sits in the dock as a native application (C?) which

    launches the JAVA application Eclipse.

    I'm going to dig in there .....

    Thanks so far.

    ;JOOP!

  • 6. Re: Is there a way to start a JAVA program from the dock?
    Barney-15E Level 8 Level 8 (35,280 points)

    Drag it to the right side of the dock. It is a document, not an app.

  • 7. Re: Is there a way to start a JAVA program from the dock?
    Barney-15E Level 8 Level 8 (35,280 points)

    Eclipse is a java "application" because it is packaged in a wrapper that makes it behave like a native app.

  • 8. Re: Is there a way to start a JAVA program from the dock?
    Sciuriware Level 1 Level 1 (0 points)

    More precise: after some vain attempts I successfully dragged it to in-between the Trash bin and the next icon to the left.

    Yes that's an improvement; now I can click the .jar which produces a coffee cup and a running application.

    Only: the keep-in-dock doesn't work.

     

    Indeed: eclipse is wrapped too.

    May I conclude that the dock is only for wrapped app's?

     

    As most of my applications are started from a few, I should only wrap those few to solve the problem.

     

    I also became aware of "TextWrangler", a program to edit plists, a.o. the Dock preferences.

    Will study that too.

     

    For the moment, thanks for your time.

    ;JOOP!

  • 9. Re: Is there a way to start a JAVA program from the dock?
    Barney-15E Level 8 Level 8 (35,280 points)

    The Dock is for Applications, Documents, and Folders (which can take several forms). There are some other odd animals that can stay in the Dock, but they were never truly implemented (recent items is one). If you "wrap" the .jar file inside some package that behaves as an application, you can have it stay in the Dock just as any other Application.

     

    A .jar file is not an application, it's a java archive. It is a collection of classes, metadata, etc. which the Java runtime interprets and executes. The Application which runs it shows up in the Dock as the coffee cup, but that is just the runtime engine, not the .jar.

     

    The .jar is like any other document, such as a a word processing document. Just like any document, it can be double-clicked and the handling application will be called to open it. Double-clicking that word processing document causes the word processing application to open the document and interpret its contents. Double-clicking the .jar file causes the java runtime engine to open the .jar file and interpret its contents. Instead of presenting it as paragraphs of text, it displays it as the application it represents.