RunJava.sh
is a shell script designed to simplify the process of compiling and executing Java projects directly from the terminal. It searches for Java source files or packages, compiles them if necessary, and executes the main Java class.
-
Clone the repository:
git clone https://github.com/Gabriel-c0Nsp/RunJava.git
-
Navigate to the repository:
cd RunJava
-
Make sure the script has executable permissions. If not, run the following command:
chmod +x RunJava.sh
-
Since this script navigates through your directories, you need to run it using the source command:
source ./RunJava.sh
You can easily run this script by simply just typing runjava
(or whatever you want) in your terminal, by setting aliases to your .bashrc
or .bash_profile
.
First, you need to identify the current directory of the repository. This can be achieved with the following command:
pwd
This output is important for the following process. The output of the pwd
command is personal and will be referred in this documentation as {current_directory}
for generalization purposes.
Finally, you can add the following instructions to your .bashrc
or .zshrc
file:
export PATH=$PATH:{current_directory}/RunJava/
alias runjava='source {current_directory}/RunJava/RunJava.sh'
Don't forget to change the path in the export PATH=...
command as needed.
Now you can try the runjava
command anywhere in your terminal and check the result.