Compiler not running file i want

Question:
i am new to replit . when i opened java templat , first code was hello world , gave output . but when i wrote another code and clicked run , it still gave output of hello world . how do i make compiler run my file.
Repl link:

code snippet

Did you write your new code inside the main.java file or did you write it inside a new file that you added?

Can you provide either a screenshot or the link to your repl for us to assist you a little easier?

That doesn’t apply to complied languages such as Java.

Aww woops. Wasn’t thinking :frowning: It’s early here.

i wrote it in a new file that i added . how do i link the code?

https://replit.com/@prathamshah485/Java#add.java . here is the link

Honestly, I would just copy everything in your add.java file into the Main.java file (erase what’s in the Main.java).

But if you want to keep both files you need to turn on “see hidden files” and modify the .replit file to tell it what to compile and run.

image

Another alternative would be - don’t use the “RUN” button. Go to the shell tab and compile / run the add.java file yourself with the javac and java commands.

1 Like

i deleted the main file . now there is only one file on my template , still the output is hello world

i will just use shell

rename add file to main file.

Will also need to rename the add class to Main and it wouldn’t hurt to delete Main.class from your files before the next compile.

2 Likes