How can you get rid of the file and replace it with another file?

How can you get rid of the file and replace it with another .java file?

You are viewing a single comment. View All

You cannot delete in, that will always be the file that is executed first.

What is your goal?


@Zavexeon to be able to execute a stand alone source file without also executing what is inside main...main executes first and then the separate source file does not run. I would like to use this in my class but I cannot because of this limitation.

The only workaround I have found is to copy the source into and then give the class file the name Main. But that limits being able to give multiple assignments to students.

bottom line, i don't want Main to be executed first.


@rdeardorff actually I don't want Main to exist. or we need to be able to rename it.


@rdeardorff Uh... well you can't delete main, but I think if you create another file you can manually compile and execute it using the shell. Press F1 while in the repl, and in the search menu that appears type in "shell" and select "open shell". I can't guarantee this will work but it's might.

Another route might be to use a polygott repl and set up a makefile to compile and run whatever java file you want.


@Zavexeon You can also in the public static void main(String[] args) method of call your target class's main method: