Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChance Edward
4,507 PointsIs something wrong with my code because it doesn't work the way I want it to.
The version of IntelliJ Craig and I are using is completely different so when I made my project it had a different formatting than the one Craig has so it makes this kinda hard to do
This is Main.java
package com.teamtreehouse.courses;
public class Main {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
get("/", (req, res) -> {
return new ModelAndView(null,"index.hbs"
}, new HandlebarsTemplateEngine());
}
}
this is Index.hbs
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello Students</title>
</head>
<body>
<h1>Welcome Students!</h1>
<!--TODO:csd - Add sign in! -->
<form action="/sign-in" method="post">
<input type="text" placeholder="What's your user name?" name="username">
<button>Sign in</button>
</form>
</body>
</html>
This is build.gradle
plugins {
id 'java'
id 'application'
id 'org.javamodularity.moduleplugin' version '1.8.12'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
}
group 'com.teamtreehouse.courses'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.9.2'
}
sourceCompatibility = '20'
targetCompatibility = '20'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'com.teamtreehouse.courses.courseideas'
mainClass = 'com.teamtreehouse.courses.courseideas.HelloApplication'
}
javafx {
version = '20'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
compile 'com.sparkjava:spark-core:2.3'
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}