r/javahelp • • Nov 25 '20

New to Java

I’m new to Java and am taking a class online. I’m having trouble understanding anything. I can’t get any program to run, even when the instructor gives me the program to copy. Can anyone explain it in terms that an idiot can understand? I can create a class...then I’m at a loss. My instructor just seems annoyed that I don’t get it. I’m afraid he’s just going to fail me without helping.

0 Upvotes

10 comments sorted by

•

u/AutoModerator Nov 25 '20

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/kAlvaro Nov 25 '20

There're many ways to run Java code. Why don't you share the code your instructor gave you to copy and explain what steps you follow and how it fails?

1

u/desrtfx Out of Coffee error - System halted Nov 25 '20

Have you considered using secondary learning resources, like the MOOC Object Oriented Programming with Java?

Simply put: if the resource you have is not good enough, use another. The internet is full of high quality resources of which plenty are free. Our sidebar here already lists a few.

1

u/RayjinCaucasian Nov 25 '20

What's the specific question?

0

u/Camel-Kid 18 year old gamer Nov 25 '20

Are you running your program from commandline or from an IDE like Eclipse/intellij? What happens when you try to run a program, what errors do you get?

0

u/CAS05140814 Nov 25 '20

I have to run in Eclipse. I guess my main question is not so specific, but I just don’t understand what to say in any given instance. Like in a normal sentence I need a noun and verb. What do I need for a Java program in general? Is there an outline I can follow? Everything I’ve tried to run says there is no main, but I enter the line that says main so I thought that’s what I needed.

0

u/Camel-Kid 18 year old gamer Nov 25 '20

Java is case sensitive so you need to make sure that your main is declared properly.. ie public static void main(String args[]).. if you confirmed that, then you can right click on the class and hit run as->java application

0

u/CAS05140814 Nov 25 '20

Ok. And if that is correct, why would it say no main?

2

u/Camel-Kid 18 year old gamer Nov 25 '20

it should only say no main if there is no main, or the main is not defined correctly... orr you are not running the right class file.

0

u/doctersaiyan Nov 25 '20

Watch a boot camp or quick tutorial on youtube to grasp the basics. It will eventually click 💡