Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Local vs. network file Date: Sun, 24 Jun 2012 20:20:50 +0200 Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net RnWwqnfYme5IfU1YkOaZYwzq537DmmZaQIgM4Bwcq3MIicXK3M74ESP7ALdrqm3Wg= Cancel-Lock: sha1:64EVrfR1BZDqEUJRNlVdFyo/u5I= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:15565 On 24.06.2012 20:01, Qu0ll wrote: > I have a requirement to limit a program which is licensed as "stand > alone" to not be run from a network location so I figured if I could > tell whether the launch directory was a network share then I could block > it. Is there another way I could implement this? Ah, now we're cooking! I am afraid you need to implement a solution for every platform your software could be used on. On *nix you could evaluate the output of "mount" to find out, on Windows you probably need to look at "net use" etc. Maybe on POSIX OS there is a system call that will help so you could write a JNI extension. This method certainly helps: http://docs.oracle.com/javase/6/docs/api/java/io/File.html#getCanonicalFile%28%29 If you want to prevent multiple instances running concurrently from one installation you could use a file in the installation location. However, proper file locking in a platform independent way is another tricky task in Java. Btw, I don't see how the installation location actually makes a difference. You could still install the program on each system and run it multiple times. Why do you need to prevent running from a network drive? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/