Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to create symbolic links within Java  RSS feed

 
Teddy Wang
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have an app that needs to create hundreds of thousands of symbolic links in a J2EE container. Currently we're using the feature to do this. 2 Questions.

  • Is there a more native way to create the symbolic links?
  • If there is no better way to do this, what's the performance ramifications of performing all of these Runtime.exec's?


  • Any help would be appreciated.

    Thanks!
     
    Ernest Friedman-Hill
    author and iconoclast
    Sheriff
    Posts: 24217
    38
    Chrome Eclipse IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There's no other way to do it than with Runtime.exec(), no. If you need to check the success of each of these operations, then this makes sense. Otherwise, you might write out a shell script, and then execute that; it will certainly be more efficient.
     
    Peter Chase
    Ranch Hand
    Posts: 1970
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Ernest Friedman-Hill:
    There's no other way to do it than with Runtime.exec(), no.


    Surely, JNI is an alternative. That is, find what Unix function calls are needed and call them in C code, which you interface to Java native methods.

    Using JNI eliminates the overhead of starting a new process. There is some overhead in calling C code from Java, but very much less than the process start-up overhead.

    That said, JNI is not all that easy. So if you can get away with Runtime.exec(), it will be much easier.
     
    Ernest Friedman-Hill
    author and iconoclast
    Sheriff
    Posts: 24217
    38
    Chrome Eclipse IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Peter Chase:


    Surely, JNI is an alternative. That is, find what Unix function calls are needed and call them in C code, which you interface to Java native methods.


    Sorry, of course. What I was really meaning to say was that Java doesn't have an API for this.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!