Unable to compile Java file in shell console, no matter what!

Hello, I am currently trying to submit my project on Replit. The problem is, we can’t use “Run”, button so we have to compile it in Shell console. I tried to compile javac filename.java And then java filename

It keeps giving me error, error: file not found: SophiaProjectRukhasar.java
Usage: javac
use --help for a list of possible options
My class name is same as file name.

I really need to submit this,I use other IDEs and code runs perfectly fine. :frowning:
Can someone please assist, I have to use Replit for coursework project?

Here is the link and screenshots also attached: https://replit.com/@solutionszilla/SophiaProjectRukhasar#src/main/java/SophiaProjectRukhasar.java

Screenshots, links, or other helpful context:

code snippet

Hello, it seems like the file you want to compile is inside a folder, so it is not being found. (The commands only search for the specified file in the current working directory, the top level files, I believe.)
Try right clicking the file you want to compile, and click Copy file path, then use that in your Shell command. (Paste with Ctrl+Shift+v)

1 Like

Thanks! I tried it, and it says: Permission denied after path name.

Hmm, I’m not sure then. I don’t use Java, so maybe someone else can help you.

Hi @solutionszilla , welcome to the forums!
Either run your code in the Main.java file provided and revert your .replit back to its original state, or:

  1. Move the file out of the folders into the root.
  2. Change the entrypoint to whatever file you would like to run.
  3. Run the repl.

Or, enter java filename.java in the Shell to see the output there, where you’ll need to chamge filename the the actual name of the file.

You can see this repl for reference.

Hope this helps!

1 Like

You may want to try running chmod +x /path/to/file.java, where /path/to/file.java is the location of your .java file.

1 Like

I really wish, I can screenshare with someone and resolve this. Since the institute only use Replit, I am literally stuck on this project. It’s still giving me error. :frowning:

I did this as well, this the the error - chmod: cannot access ‘/path/to/SophiaProjectRukhasar.java’: No such file or directory

:frowning:

Try running chmod +x src/main/java/SophiaProjectRukhasar.java.

While compiling, I get this error now: java SophiaPrerror: Class names, ‘java.SophiaProjectRukhasar’, are only accepted if annotation processing is explicitly requested
1 error

Now this error.

error: file not found: SophiaProjectRukhasar.java
Usage: javac <options> <source files>

Try forking the repl and follow the steps I showed. In the repl, the src directory is removed, and the file is called test.py. You can write the code inside there and run it.
If you want to rename the file, rename it, then change the entrypoint in the .replit file to the new filename (don’t change anything else).
Or, run java filename.java, where filename is the name of the file you want to run.

I followed your instruction, I still get this error
https://replit.com/@solutionszilla/project7
Can you please assist further.
I attached the link as well. I just need this project to compile and run, so my project can be submitted. I am a beginner learning Java, and I am so tired with this error. It’s been 3 days now. :confused:

Hi there, the repl seems to be private or deleted.
Could make it public/restore the repl?
Thanks!