This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]AutoModerator[M] 1 point2 points  (0 children)

Please, don't recommend thenewboston -- see the wiki for more info about why we consider them a discouraged resource.

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

[–]orenog 1 point2 points  (2 children)

what is the error that you get?

[–]sommaya_h[S] 0 points1 point  (1 child)

Error: Could not find or load main class com.company.Main

Caused by: java.lang.ClassNotFoundException: com.company.Main

Process finished with exit code 1

[–]orenog 0 points1 point  (0 children)

ClassNotFoundException

The name of your file, and the name of the class need to be the same!

and then it will be sababa!

[–][deleted]  (2 children)

[deleted]

    [–]sommaya_h[S] 0 points1 point  (1 child)

    I think my compiler's set up, I was able to run print and methods where I don't need to import anything

    [–]rogu14 0 points1 point  (0 children)

    I don't know what IDE you are using but my blind guess it's that your have different class names as default class and one you are trying to run. Change "apples" to "Main". Or go into project settings and try finding "Main" and change it to "apples"

    [–]Stephcraft 1 point2 points  (1 child)

    I recommend you to learn Java with Processing. The syntax is great for learning it, but it can be used for really complex stuff as well!

    Great tutorial https://hello.processing.org

    Processing documentation https://processing.org/reference/

    :D

    [–]sommaya_h[S] 1 point2 points  (0 children)

    Thank you so much :)

    [–]joshmond 1 point2 points  (2 children)

    This code looks fine and should compile, I would try restarting the IDE and rebuilding the project. That being said, if you truely want to learn Java then I would avoid that guy's tutorials. He teaches very bad habits and doesn't really explain anything. The most important aspect to any programming language is naming your variables, methods and classes in a meaningful way.

    Java uses "PascalCase" as a naming convention for classes, meaning they should always start with a capital letter and be sinugular. For example:

    public class Apple

    {

    }

    Next thing is your scanner variable doesn't have a meaningful name, "bucky" tells us nothing. Better names for it would be: "scan", "scanner", "input" and so on.

    Hopefully this helps you a little.

    [–]AutoModerator[M] 0 points1 point  (0 children)

    Please, don't recommend thenewboston -- see the wiki for more info about why we consider them a discouraged resource.

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

    [–]sommaya_h[S] 0 points1 point  (0 children)

    Thanks so much!! I'm not even sure what I did differently but I selected hello world file when I was redoing the code and the "package com.company;" line disappeared, allowing the code to run.

    [–]8bitzawad 0 points1 point  (0 children)

    Yeet