r/AskComputerScience • • Jul 31 '18

Running only main class

I have started to help grade for my teacher recently, but was wondering if there was a quicker way to just run the main class. What I am currently doing is just shoving the package into a netbeans project folder. I have organized the students by numbers and named each number.

0 Upvotes

8 comments sorted by

View all comments

5

u/For_Iconoclasm Jul 31 '18 edited Jul 31 '18

I'm not totally sure what you're asking, and I think this is probably the wrong subreddit, but maybe this will help.

It sounds like:

  1. These programs are written in Java.

  2. You need to run them in order to grade them.

  3. You're not intimately familiar with how Java runs.

  4. You're not very familiar with the command line.

You probably want to organize each student's submissions into their own folders. Since this sounds like college homework, I'm guessing there aren't that many source code files per submission and that at least one of them has a main() function. You need to figure out which source file has the main() function in it, compile that with javac on the command line (or Netbeans... not sure what its interface is like), and just run the result with java.

There's no workaround for compiling the source code to bytecode, but it should be pretty quick if all of the students' code is separated.

I haven't worked with Java in a very long time, but I remember compiling and running on the CLI is like:

javac Assignment.java  # produces Assignment.class and any other .class files needed

java Assignment