Renato Lochetti
Renato Lochetti

Reputation: 4568

Java Web Start - Multiple shortcuts

I'm having a problem with creating shortcuts at versions of WindowsXP that aren't in English.

I want to add a shortcut to the 'Startup' menu, that way, the application will run every time the user log on.

So i did:

<shortcut online="true">
    <desktop/>
    <menu submenu="Startup"/>
</shortcut>

But, at WindowsXP in Portuguese, for example, the correct submenu need to be 'Inicializar' instead of 'Startup'.

So, considering that application's users may have English or Portuguese versions of Windows, I need something like that:

<shortcut online="true">
    <desktop/>
    <menu submenu="Startup"/>
</shortcut>
<shortcut online="true">
        <desktop/>
        <menu submenu="Inicializar"/>
</shortcut>

But that doesn't work.

Can anyone help?

Thanks.

Upvotes: 2

Views: 507

Answers (2)

Heitor Rosa
Heitor Rosa

Reputation: 31

I did this in my app:

 public static void main(String[] args) {
        IntegrationService is = null;
        String osName = System.getProperty("os.name");

        try {
            is = (IntegrationService) ServiceManager.lookup("javax.jnlp.IntegrationService");
        } catch (UnavailableServiceException use) {
            use.printStackTrace();
        }
        if (!is.hasMenuShortcut()) {
            if (osName.equals("Windows 7")) {
                is.requestShortcut(false, true, "Startup");
            } else {
                is.requestShortcut(false, true, "Inicializar");
            }
        }
        SystemTrayTest main = new SystemTrayTest();
    }

So in Windows XP the shortcut is created in "Inicializar" and Windows 7 in "Startup".

Upvotes: 3

Andrew Thompson
Andrew Thompson

Reputation: 168825

The JNLP format supports partitioning downloads by locales in the resources elements, but not the shortcuts element (from memory - use JaNeLA to check for sure).

Instead, you will probably need to look to the IntegrationService introduced in 6.0.18. Particularly the requestShortcut(desktop,menu,submenu)1 method. The method returns a boolean to indicate success/failure.

  1. The string for submenu might be inferred from:
    • user.language
    • Locale.getDefault()
    • The simple solutions - ask the user:
      1. Editable combo-box of known variants in an option pane.
      2. A file chooser, pointing to somewhere near where the start menu should be.

Upvotes: 3

Related Questions