Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

How to create alias in Mac using java

 
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
 
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.
 
author
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?
 
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
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
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!