Having Trouble Running a Java GitHub Repo in Replit

Here’s my code: TryCatcherDemo - Replit

After cloning my working GitHub program, I added a .replit file consisting of: run = “sh main.sh”
I added a main.sh consisting of: javac *.java; java Catcher

I’m getting the error: unable to run, main file “main.sh” not found. Any ideas what I’m doing wrong?

1 Like

I couldn’t get it working from your link, but got it working through a manual import. Hopefully you can work back the usage from there? https://replit.com/@DavidAtReplit/exampleWorkingJava

1 Like

Thank you so much, David, for the time you obviously spent with that, but I can’t get it to work with the link you sent me (not even trying to fix my replit yet) Is a .replit file with that level of detail and a replit.nix file always required to run something from GitHub?

No - it was just the quickest way for me to get the java file running. I’ll have another look - or if anyone else in the community has any better advice?

I got it working: TryCatcherDemo-1 - Replit

The .replit file can’t be inside a folder or else it won’t be seen. You have to drag it to the main directory. If it disappears, you can view it by clicking the three dots at top right of the Files tab, and then click “Show hidden files”. It should then appear under “Config files”.

I also made some small changes to the .replit file:

run="sh Catcher/main.sh"

And to the main.sh file:

cd Catcher/src
javac Catcher.java
java Catcher

Hopefully this helps!