I built a runnable JAR from an Eclipse project that processes a given XML file and extracts the plain text. However, this version requires that the file be hard-coded in the code.
Is there a way to do something like this
java -jar wiki2txt enwiki-20111007-pages-articles.xml
and have the jar execute on the xml file?
I've done some looking around, and all the examples given have to do with compiling the JAR on the command line, and none deal with passing in arguments.
Why not ?
Just modify your Main-Class
to receive arguments and act upon the argument.
public class wiki2txt { public static void main(String[] args) { String fileName = args[0]; // Use FileInputStream, BufferedReader etc here. } }
Specify the full path in the commandline.
java -jar wiki2txt /home/bla/enwiki-....xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With