how to run java files.
Hello, I was wondering how I can run the main.java and any other .java file in replit. In python I am able to import the os and pass in the file on os.system() but I am unable to do it with Java and I noticed that new files are created that I have no idea what they are. I will be doing a java bootcamp course and I want to make sure I am able to run java code without problem.
you can do that by,
first compiling your myfile.java (make sure your main class which contain void main and your myfile name is same, else wont work) by typing in your console:
then run your myfile.java:
It's 2 step process in repl editor(Compile and Run)
Step 1: Click Run button (main.java runs repl also compile your other.java class and creates other.class)
Step 2: java other (in command prompt, this will run your other.java file).
Java is object oriented robust language and Platform-Independent. Java only has Android development. It needs some learning to enjoy this language and it has future.
i only know how to do it on windows: go to the command prompt, go to the directory of the file, type 'javac' and then the program. then, you will see another file. type in 'java' and then the new file's name. then you should see something in the command prompt (for example, 'Hello, world!') (this is if you want to run from the windows terminal, as a file)