Reputation: 373
I have made a java program composed of two files: fibonacci.java and customBigInteger.java. The customBigInteger.java is the implementation of adding big integers together without the use of BigInteger data type from the java library (a requirement for my assignment). This is used in fibonacci.java to calculate the n-th fibonacci number.
I wrote these in eclipse, but another requirement of the assignment is to write one shell script to compile and run the program, which I have never done before. How do I do that, assuming i have both .java files in the /bin/usr/Documents directory?
Upvotes: 1
Views: 1043
Reputation: 201487
Create a file to compile and run, assuming your classes are in the root package and assuming you want the compiled class files in the same folder and that fibonacci
contains main
then something like
#!/usr/bin/env bash
javac fibonacci.java customBigInteger.java
java -cp . fibonacci
should do it. Assuming you have saved the above as fibonacci.sh
then you need to give it the execute bit.
$ chmod 755 fibonacci.sh
Note that Java class names should start with a capital letter by convention.
Upvotes: 2