r/learnjava • • Jan 14 '20

Main Class

I am just starting to learn Java. I am using IntelliJ on mac. I cannot even run hello world. It says could not find or load main class. I can't find what the main class is or how to add it. I have been trying to fix the run configuration for an hour. Please help me before I quit CS after 2 weeks

1 Upvotes

9 comments sorted by

4

u/[deleted] Jan 14 '20

Update figured it out

2

u/shinefull Jan 14 '20

Always put in your comment what was the problem and what was your solution. Or just don't comment.

7

u/sd_owens Jan 14 '20

All Java programs run from main(). It is the first function (method) that is run and all others follow from there. When you start IntelliJ you should select new project and it will build a Hello World program for you with a main method. If you don’t know what main() is I highly recommend a book or YouTube videos.

To be real, if you can’t find the answers above with a quick google and give up after two weeks maybe CS is not right for you.

1

u/keyserS13 Jan 14 '20

If have some code add edit you post and add the code. Otherwise, did you make sure your class is in the src folder?

1

u/[deleted] Jan 14 '20

What is an src folder?

1

u/keyserS13 Jan 14 '20

Its the folder that contains all the contents of your intellij project (including the main class). It should be in the leftmost side of your window. If you expand everything you should see it

1

u/DammitJoe00 Jan 14 '20

I dont use intelija but on elicipse you have to check the "public static void main (String args[])" box to create your main class. You can try adding that line of code or creating a new main class.

Sorry if that doesnt help, I'm also a beginner.

1

u/Migeil Jan 15 '20

Also java != CS.