-1

I have a Main java class which has the main() method. In this method I want to use another class of that I wrote Person. Both classes are under the same package so I understand I don't need to import the Person class and I can use it right away.

Should I compile the Person class first and then the Main or not?

I tried to compile just the main and I got error:

cannot find symbol Person

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • If you use an IDE, such as IntelliJ or Eclipse, you never have to worry about issues like this. – Dawood ibn Kareem Mar 23 '22 at 21:31
  • check this, it's about making a Jar containing many .class file, but should point you to the right direction also with compilation https://stackoverflow.com/questions/9941296/how-do-i-make-a-jar-from-a-java-file/9941411#9941411 – BigMike Mar 23 '22 at 21:38

1 Answers1

2

My question is should I compile the Person class first and then the Main or not.

You could, but there is no need to do that given the simple requirements you describe. The 2 could be compiled together if you like. You do not necessarily need to compile Person first.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47