How to make call to a package location in a code
Hi there
I have a lucene package which indexes files using the following command
java org.apache.lucene.demo.IndexFiles
Now I can use this on the command line but I would like to make some java code that automatically interacts with this code .
That line accepts two parameters in the following way:
java org.apache.lucene.demo.IndexFiles -docs "path where your corpus resides" -index "path
where you want the created index files to be saved"
How can I make some code in java so that I call that line and pass it the following parameters :
-docs accepts the path where I have the file with my data, do I have necessarily have to pass it the path or can I also load the data I want to process in a variable and pass that variable as a file to the indexFiles class?
If not, how can I run that class using java code ?
Thank you
Re: How to make call to a package location in a code
Look at the Desktop and Runtime classes. You can call OS commands with methods in those classes.
Re: How to make call to a package location in a code
Also google for using ProcessBuilder, there are loads of examples on how to use it.
There are also a few gotchas on using Process objects (as created by ProcessBuilder and Runtime.exec()) so I'd recommend you also read this article.
Re: How to make call to a package location in a code
thank you guys,
I didnt know what to look for but those terms what you suggested have given me some good help.