This repository contains a Java console application and environment setup scripts for Java development.
Java_Txt_Project_Space/
├── LICENSE
├── README.md
└── Test_Console/
├── Test_Console.java # Main Java application
├── Test_Console.class # Compiled Java bytecode
├── Test_Console.mf # Manifest file for JAR creation
├── SetEnviromentVar.ps1 # PowerShell environment setup script
├── SetEnviromentVar.bat # Batch environment setup script
├── ExecuteTestConsole.ps1 # PowerShell execution script
└── ExecuteTestConsole.bat # Batch execution script
A simple Java console application that:
- Prints "Hola Mundo" (Hello World)
- Reads user input from console
- Demonstrates basic Java I/O operations
PowerShell script to configure Java environment variables for development with automatic Java version detection and selection.
Usage:
# Set execution policy (if needed)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Run with default Java version (jdk1.6.0_45)
.\SetEnviromentVar.ps1
# Run with specific Java version
.\SetEnviromentVar.ps1 -JavaVersion jdk-11
.\SetEnviromentVar.ps1 -JavaVersion jdk-17Windows batch script to configure Java environment variables for development with automatic Java version detection and selection.
Usage:
# Run as administrator (recommended) with default Java version (jdk1.6.0_45)
SetEnviromentVar.bat
# Run with specific Java version
SetEnviromentVar.bat -java jdk-11
SetEnviromentVar.bat -java jdk-17PowerShell script to automatically compile and execute the Test_Console Java application with different execution modes.
Note: Run from the Test_Console folder, or use .\Test_Console\ExecuteTestConsole.ps1 from the project root.
Usage:
cd Test_Console
# Execute with default mode (class files) and default Java version (jdk1.6.0_45)
.\ExecuteTestConsole.ps1
# Execute with specific mode
.\ExecuteTestConsole.ps1 -ExecutionMode jar
.\ExecuteTestConsole.ps1 -ExecutionMode class-package
.\ExecuteTestConsole.ps1 -ExecutionMode jar-package
# Execute with specific Java version
.\ExecuteTestConsole.ps1 -JavaVersion jdk-11
.\ExecuteTestConsole.ps1 -JavaVersion jdk-17
# Combine execution mode and Java version
.\ExecuteTestConsole.ps1 -ExecutionMode source -JavaVersion jdk-17
.\ExecuteTestConsole.ps1 -ExecutionMode jar -JavaVersion jdk-11
.\ExecuteTestConsole.ps1 -ExecutionMode jshell -JavaVersion jdk-17Available execution modes:
source: Execute directly from source code (Java 11+)class(default): Compile and run with *.class filesclass-package: Compile and run with *.class files and packagejar: Compile, create JAR, and run with *.jar filesjar-package: Compile, create JAR with package, and runjshell: Launch JShell interactive REPL (Java 9+)
Windows batch script to automatically compile and execute the Test_Console Java application with different execution modes.
Note: Run from the Test_Console folder, or use Test_Console\ExecuteTestConsole.bat from the project root.
Usage:
cd Test_Console
# Execute with default mode (class files) and default Java version (jdk1.6.0_45)
ExecuteTestConsole.bat
# Execute with specific mode
ExecuteTestConsole.bat -source
ExecuteTestConsole.bat -jar
ExecuteTestConsole.bat -jshell
ExecuteTestConsole.bat -class-package
ExecuteTestConsole.bat -jar-package
# Execute with specific Java version
ExecuteTestConsole.bat -java jdk-11
ExecuteTestConsole.bat -java jdk-17
# Combine execution mode and Java version
ExecuteTestConsole.bat -source -java jdk-17
ExecuteTestConsole.bat -jar -java jdk-11
ExecuteTestConsole.bat -jshell -java jdk-17Available execution modes:
-source: Execute directly from source code (Java 11+)-class(default): Compile and run with *.class files-class-package: Compile and run with *.class files and package-jar: Compile, create JAR, and run with *.jar files-jar-package: Compile, create JAR with package, and run-jshell: Launch JShell interactive REPL (Java 9+)
All scripts now support automatic Java version detection and selection from C:\Program Files\Java.
- Automatic Detection: Scans
C:\Program Files\Javafor available JDK/JRE installations - Default Version: Uses
jdk1.6.0_45as default (configurable) - Version Display: Shows all available Java versions with the selected one highlighted
- Fallback: If specified version not found, uses first available version
- Cross-Platform: Works with any Java version naming convention (jdk-11, jdk-17, jdk1.8.0_XXX, etc.)
- PowerShell:
-JavaVersion(e.g.,jdk-11,jdk-17,jdk1.8.0_XXX) - Batch:
-java(e.g.,jdk-11,jdk-17,jdk1.8.0_XXX)
- PowerShell:
-JavaVersion(e.g.,jdk-11,jdk-17,jdk1.8.0_XXX) - Batch:
-java(e.g.,jdk-11,jdk-17,jdk1.8.0_XXX)
Environment Setup:
# Set environment with default Java version
.\SetEnviromentVar.ps1
# Set environment with Java 11
.\SetEnviromentVar.ps1 -JavaVersion jdk-11# Set environment with default Java version
SetEnviromentVar.bat
# Set environment with Java 11
SetEnviromentVar.bat -java jdk-11Application Execution:
# Use Java 11
.\ExecuteTestConsole.ps1 -JavaVersion jdk-11
# Use Java 17 with source execution
.\ExecuteTestConsole.ps1 -ExecutionMode source -JavaVersion jdk-17# Use Java 11
ExecuteTestConsole.bat -java jdk-11
# Use Java 17 with source execution
ExecuteTestConsole.bat -source -java jdk-17Both scripts set the following environment variables:
- JAVA_HOME:
C:\Program Files\Java\jdk1.6.0_45 - PATH: Adds
%JAVA_HOME%\binto system PATH - CLASSPATH: Set to
.(current directory)
CLASSPATH=.;+ n values; or CLASSPATH=.;+ n values; + package;
PATH=C:\Program Files\Java\jdk1.6.0_45\bin;+ n values;
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_45;
# Launch JShell interactive REPL
jshell
# Use /help for commands, /exit to quit# Run directly from source without compilation
java Test_Console.java# Compile
javac -g -cp . Test_Console.java
# Run
java Test_Console
java -cp . Test_Console# Compile
javac -g -cp . Test_Console.java
# Run (from parent directory)
cd ..
java Test_Console.Test_Console# Compile
javac -g -cp . Test_Console.java
# Create JAR
jar -cmf Test_Console.mf Test_Console.jar Test_Console.class
# Run
java -jar Test_Console.jar# Compile
javac -g -cp . Test_Console.java
# Create JAR (from parent directory)
cd ..
jar -cmf Test_Console\Test_Console.mf Test_Console.jar Test_Console\*.class
# Run
java -jar Test_Console.jarMain-Class: Test_Console
Note: Each line ends with CR+LF character on Windows OS
Important: The manifest file is configured for the current state where the package declaration is commented out. If you uncomment the package declaration in Test_Console.java, you would need to change the manifest to Main-Class: Test_Console.Test_Console.
When using packages, the main class and main file names must be the same for both object and source files.
- Java Development Kit (JDK) 1.6.0_45 or compatible version
- Windows operating system
- PowerShell (for .ps1 script) or Command Prompt (for .bat script)
- Clone or download this repository
- Run the appropriate environment setup script:
- For PowerShell:
SetEnviromentVar.ps1 - For Batch:
SetEnviromentVar.bat
- For PowerShell:
- Restart your terminal or IDE for environment changes to take effect
- Use the execution scripts (from the
Test_Consolefolder) to compile and run the Java application:- For PowerShell:
cd Test_Consolethen.\ExecuteTestConsole.ps1 - For Batch:
cd Test_ConsolethenExecuteTestConsole.bat
- For PowerShell:
-
Setup Environment:
# Run as administrator with default Java version (jdk1.6.0_45) SetEnviromentVar.bat # Or setup with specific Java version SetEnviromentVar.bat -java jdk-11
-
Execute Application:
cd Test_Console # Execute directly from source (Java 11+) ExecuteTestConsole.bat -source # Simple execution with class files (default Java version) ExecuteTestConsole.bat # Or create and run JAR file ExecuteTestConsole.bat -jar # Use specific Java version ExecuteTestConsole.bat -java jdk-11 ExecuteTestConsole.bat -source -java jdk-17 ExecuteTestConsole.bat -jshell -java jdk-17
- The environment setup scripts require administrator privileges to modify system environment variables
- After running the setup scripts, you may need to restart your development environment
- The scripts are configured for JDK 1.6.0_45 - modify the paths if using a different Java version
- CATALINA_HOME is included as a commented option for Tomcat development (uncomment if needed)
- The execution scripts automatically handle compilation and provide multiple execution modes
- All scripts include error checking and informative output messages
- Source execution mode requires Java 11 or higher; older versions will fall back to compilation mode
- JShell mode requires Java 9 or higher; use
-ExecutionMode jshell(PowerShell) or-jshell(Batch) with a JDK 9+ (e.g.jdk-11,jdk-17)
This project is licensed under the MIT License - see the LICENSE file for details.
- ✅ Commercial use allowed
- ✅ Modification allowed
- ✅ Distribution allowed
- ✅ Private use allowed
- ❌ No liability or warranty provided