Hello, guys! I just created my first http4k app th...
# http4k
j
Hello, guys! I just created my first http4k app through your magical wizard and it yields me this error:
Error: Main method not found in class com.example.HelloWorldKt, please define the main method as:
public static void main(String[] args)
... and that is yucky Java stuff... What should I put in my
fun main()
function?
d
I suspect this may be something regarding your envirionment. Just to make sure - I've just generated a completely vanilla toolbox and run the main class from the IDE.. It worked:
How did you run your app?
j
Using the gradle target "run", I can't
No main function
Screenshot 2024-03-29 at 22.32.06.png
d
yeah - ok - this is a problem because you're using a serverless function instead of a server app. But it's easy to get it running. You should already have TestApp.kt - add a couple of lines and then run it from there..
Copy code
package com.example

import org.http4k.server.SunHttp
import org.http4k.server.asServer

val app = HelloWorldAppLoader(emptyMap())

fun main() {
    app.asServer(SunHttp(8000)).start()
}
Then you can browse to:
Copy code
<http://localhost:8000/ping>
j
Ok, it works now! Thanks!
👍 1