Why does the code output read
sh -c javac -classpath .:target/dependency/* -d . $(find . -type f -name '.java’)
java -classpath .:target/dependency/ Main
Hello world!
It seems that you are attempting to run a different file other than Main.java
. Can you send a code link?
I can’t solve this without a code link =/
if you are confused on why it is saying
sh -c javac -classpath .:target/dependency/* -d . $(find . -type f -name '.java’)
java -classpath .:target/dependency/ Main
that is just saying what file the compiler is running (I think)
The second line, java -classpath .:target/dependency/ Main, is the command to run the program. It specifies the classpath and the name of the main class to execute.
This happened with me on my site: http://billonilne.pk/
When I replace the path with the path to my project’s class, it runs the file but all of the other classes in my project are suddenly unavailable. This is very poor design on the part of replit, because now I have to make a guess as to why my other java classes (.java files) aren’t being compiled to class files, and all signs point to the part of the command with .:target/dependency/
and I have no idea why that string has a dot followed by a colon. If this is some hacky virtual path specific to replit’s environment, then that is straight up bullshit and needs to be explained.
To clarify my previous reply, it runs the program but then fails whenever my code uses one of the other objects in my project. This means those class files don’t exist—but “why?” is the question.
I imported a java project from GitHub to use replit. I see that javac and java have a --source-path
command line switch which is NOT configured for the project after import. Whoever the hell works at replit needs to fix that. There is no excuse. You need to force the user to specify a source path during import or have code that detects it automatically. There’s basically no reason not to try that. Use that same fancy ass $find command from the compile and run lines to find the first folder with .java files in it, and use a breadth-first search.