JHP has the following requirements:
- Java 25 or higher (Java 24 supported)
- Maven 3.6+ (for building)
- ANTLR 4.13.2 (automatically managed by Maven)
Add the following dependency to your pom.xml:
<dependency>
<groupId>com.hindbiswas.jhp</groupId>
<artifactId>jhp</artifactId>
<version>1.0.0</version>
</dependency>The artifact is available on Maven Central, so no additional repository configuration is needed.
git clone https://github.com/hind-sagar-biswas/java-hypertext-preprocessor.git
cd java-hypertext-preprocessormvn clean installThis will:
- Generate ANTLR parser and lexer classes
- Compile all source files
- Run the test suite
- Package the JAR file
- Install to your local Maven repository
If you want to skip tests during build:
mvn clean install -DskipTestsTo create a JAR file without installing to Maven repository:
mvn clean packageThe JAR file will be created in the target/ directory.
Verify your installation by running the test suite:
mvn testYou should see output indicating all tests passed:
Tests run: 88, Failures: 0, Errors: 0, Skipped: 0
Create a simple test program to verify JHP is working:
import com.hindbiswas.jhp.*;
import com.hindbiswas.jhp.engine.*;
public class TestJHP {
public static void main(String[] args) throws Exception {
Settings settings = Settings.builder().build();
FunctionLibrary lib = new FunctionLibrary();
JhpEngine engine = new JhpEngine(settings, lib);
Context ctx = new Context();
ctx.add("message", "JHP is working!");
// Create a simple template file
java.nio.file.Files.writeString(
java.nio.file.Path.of("test.jhp"),
"{{ message }}"
);
String result = engine.render("test.jhp", ctx);
System.out.println(result); // Output: JHP is working!
}
}- Read the Getting Started guide
- Learn about Template Syntax
- Explore Configuration options