jv is a command line tool written in C that allows you to compile, run code, and build simple Java projects quickly and easily. With JV, you will be able to:
- Build simple Java projects with a basic file structure for a project.
- Compile Java code and generate .class files.
- Generate executable .jar files from compiled Java code.
- Run Java code and .jar files.
- Java Development Kit (JDK) 1.8 or later installed.
- javac and java commands added to the system PATH.
jv provides several commands for automating Java project setup, compilation, and execution. Here is a list of available commands:
-
jv --new <project_name>
Creates a new Java project with the specified name. This command will generate a basic file and folder structure for your project, including a Main.java file with a basic main function.- The project created with this command will have the following structure:
<project's name>/ ├── build/ ├── bin/ └── src/ └── Main.java
- The project created with this command will have the following structure:
-
jv <class_name>
Compiles and runs the specified class. -
jv -c <class_name>
Compiles the specified Java file and generates a .class file in the build folder. -
jv -j <jar_name> <class_name>
Compiles the specified Java file and generates an executable .jar file in the bin folder. -
jv --run <file_name>
Runs the specified Java file or .jar file.
To use jv, you must first compile the jv.c file and add the resulting executable to your system's path.
To compile jv.c, you will need a C compiler such as gcc. Follow these steps to compile the file:
- Open a terminal window.
- Navigate to the directory where jv.c is located.
- Run the following command to compile jv.c:
gcc jv.c -o jv
This will create an executable file named jv in the same directory.
To use jv from anywhere on your system, you must add the directory where the jv executable is located to your system's path. Follow these steps to add jv to your path:
Open the Start menu and search for "Environment Variables".
- Click "Edit the system environment variables".
- Click the "Environment Variables" button.
- Under "System variables", scroll down and find the "Path" variable.
- Click "Edit".
- Click "New" and enter the full path to the directory where the jv executable is located.
- Click "OK" on all open windows to save your changes.
-
Open a terminal window.
-
Run the following command to open your shell's configuration file:
nano ~/.bash_profile
Note: If you use a different shell, replace
~/.bash_profile
with the configuration file for your shell (e.g., ~/.zshrc for zsh). -
Add the following line to the file:
export PATH=$PATH:/path/to/directory
Replace
/path/to/directory
with the full path to the directory where the jv executable is located. -
Press Ctrl+X, then Y, then Enter to save the file.
-
Run the following command to update your shell:
source ~/.bash_profile
Note: If you use a different shell, replace
~/.bash_profile
with the configuration file for your shell.
If you would like to contribute to this project, you can send a Pull Request or create an ISSUE. Any contribution is welcome.