Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create alias in Mac using java

 
Lucky Dhar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Seamus Minogue
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U GUYS ARE INCREDIBLE!!!

Thanks a lot for helping me out.

Thanks
Lucky
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic