I am new to coding as part of a class, but I know enough to know this shouldn’t happen.
Every time I run my code, it always prints “Hello world!” rather than what I have asked it to print. How do I fix this, I have tried creating new projects with the same code and it has done the same thing every time. Help, please.
Hey @ThomasGruszkos welcome to the forums!
Thats because the repl is running the file main.java
file. You can either add the code in that file or edit the entry point in the .replit
file so it runes a different file/
This is because you’re working in a file called health.java
. I believe it only runs main.java
. You can move your code in there OR change the entrypoint in the .replit
file to be your health.java
file.
Lol, you posted just a few seconds before I did.
Unfotently I am going to ban you for plagiarism of my answer and I will need to report your main account to site mods
Hi there @ThomasGruszkos, by default Replit is looking for the Main
class. If you want your health
class to be the like the base object, you’ll need to change the run
field in the .replit
file (click “show hidden files” after clicking the 3 dots at the top of the filetree) to: java -classpath .:target/dependency/* health
(note the changed class name at the end).
As a bonus, if you wish for your health.java
file to be shown when you load into the repl, you can change the entrypoint
field to health.java
.