Wednesday, November 17, 2010

How can I change a directory (cd to somedirectory';) in java on unix?

I haven't tried this myself, but you can use soemthing called JNI (java native method interface), to do this. Basically, if you have a method that is coded in C (such as 'cd' in unix), you can declear the same method signature in Java - along with the keyword 'native' which tells the JVM that this method has been coded in a platform-dependent language.



Thus, you can use use unix commands as methods in your java programs. For more information, check out the following resources:



- http://en.wikipedia.org/wiki/JNI

(has examples and a good introduction)



- http://java.sun.com/developer/onlineTrai



These should help you get started.How can I change a directory (cd to somedirectory';) in java on unix?
I believe you would do it the same way you would in Windows. From my understanding about Java, it works just the same on all operating systems. I could be wrong, though. I've never looked into Java that much, myself.
  • Blankets
  • short hair cut
  • No comments:

    Post a Comment