aspose file tools*
The moose likes Mac OS and the fly likes How to create alias in Mac using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "How to create alias in Mac using java" Watch "How to create alias in Mac using java" New topic
Author

How to create alias in Mac using java

Lucky Dhar
Greenhorn

Joined: Jul 02, 2008
Posts: 7
Hi Everyone,

I am working on a project in Mac OS.And the requirement is that after clicking a button ,a shortcut should be made on the desktop and a pdf file should open.
I need to implement this using java.
I have made the whole Gui in Swings.
Even if we click the shortcut which is made on desktop, the same pdf needs to be launched.

Thanks
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Hey Lucky, welcome to Javaranch.

I cannot help you with your problem, but other folks might be able to. You can help them help you if you post what you have done or tried so far. Don't be shy, show us your code.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Lucky, do you know you'll be running on a *NIX machine rather than Windows?
If you do, then perhaps you could use the ln UNIX command line tool to create a symbolic link, running the command through java.lang.Runtime?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Seamus Minogue
Ranch Hand

Joined: Jun 24, 2008
Posts: 41
Well according to your subject this is on a Mac... So I am assuming its Mac OSX rather than windows running on your mac?

I think Lasse Koskela is right on the mark to use the ln command.



For information about how to execute this command from within java take a look at this article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Lucky Dhar
Greenhorn

Joined: Jul 02, 2008
Posts: 7
Hi Everyone.

I tried to implement your suggestions by using
Runtime.getRuntime().exec("ln -s /Users/abc/desktop/text1.pdf /volumes/newcd/mac.pdf");

It is not giving any error while executing.
But a link file is not created on the Desktop.

Please advise.

Thanks,
Lucky
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Did you check the Process object's return code with Process#waitFor()? You see, the process can fail without any exceptions being thrown (usually exiting a non-zero return code).

The following works on my machine (OSX 10.5):
Lucky Dhar
Greenhorn

Joined: Jul 02, 2008
Posts: 7
U GUYS ARE INCREDIBLE!!!

Thanks a lot for helping me out.

Thanks
Lucky
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create alias in Mac using java