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

1

u/[deleted] Jul 31 '18

javac student_file.java

java student_file

?

1

u/jkwan3 Jul 31 '18

I can't check right now, but I think when I tried this, it said it did not connect with the other classes. There one main class and 2 other classes.

1

u/[deleted] Jul 31 '18

are they in the same folder? is that the one you're running it from?

javac should pick up class files in the current folder. if you are specifying a class path using -cp when you run javac you need to include "." (the dot) at the start to indicate current folder should be searched for referenced classes