linux - Running Java from terminal : cannot find text files -
i using java in eclipse file manipulation editing, searching, etc. instance have 2 text files. 1 "sales.txt" , other "employees.txt". user supposed input beginning date , ending date arguments. program finds dates match , between. there computes commission employees in found sale dates for.
here's problem: using kali linux (debian) , have create shell script compiles , runs java program command line arguments.
for example: shell script called "runner". type: ./runner [start date] [end date]
upon doing compiles fine no warnings. when program executed terminal shows this: cannot find employees or sales .txt when use run configurations in eclipse , edit arguments panel [start date] [end date] program runs fine.
here projects panel looks in eclipse:
edit - here test shell script:
#! /bin/bash javac /$home/workspace/java\ projects/database_2/src/src/*.java cd /$home/workspace/java\ projects/database_2/src java src.runner $1 $2
edit 2 - terminal output > ./testrunner 01/01/2015 01/07/2015
java.io.filenotfoundexception: employees.txt (no such file or directory) @ java.io.fileinputstream.open0(native method) @ java.io.fileinputstream.open(fileinputstream.java:195) @ java.io.fileinputstream.<init>(fileinputstream.java:138) @ java.util.scanner.<init>(scanner.java:611) @ src.commissionmodifier.parseemployees(commissionmodifier.java:101) @ src.commissionmodifier.process(commissionmodifier.java:15) @ src.runner.handlearguments(runner.java:10) @ src.runner.main(runner.java:6) java.io.filenotfoundexception: sales.txt (no such file or directory) @ java.io.fileinputstream.open0(native method) @ java.io.fileinputstream.open(fileinputstream.java:195) @ java.io.fileinputstream.<init>(fileinputstream.java:138) @ java.util.scanner.<init>(scanner.java:611) @ src.commissionmodifier.parsesales(commissionmodifier.java:135) @ src.commissionmodifier.process(commissionmodifier.java:16) @ src.runner.handlearguments(runner.java:10) @ src.runner.main(runner.java:6)
in eclipse, working folder project folder. looking @ script, that's /$home/workspace/java\ projects/database_2. i'd bet files in folder too, why works in eclipse.
when run script, changing folder /$home/workspace/java\ projects/database_2/src doesn't have files.
if assumptions true, script needs cd /$home/workspace/java\ projects/database_2 instead. java won't able find classes there, you'll need add classpath command line arguments too.
#! /bin/bash javac /$home/workspace/java\ projects/database_2/src/src/*.java cd /$home/workspace/java\ projects/database_2 java -cp src src.runner $1 $2
Comments
Post a Comment