/r/learnjava

Photograph via snooOG

Resources for learning Java


Resources for learning Java



  • No JavaScript. Please use /r/javascript instead.
  • No Android. Please use /r/androiddev instead.
  • No MineCraft Please use /r/Minecraft instead.
  • No Processing Please use /r/processing instead.
  • No links to your stackoverflow questions - we are not a second opinion to stackoverflow, nor are you going to get answers here when you didn't get satisfying ones there.
  • No Rewards: You may not ask for or offer payment when giving or receiving help.
  • Do not delete your posts! Deleting is selfish and will deprive others of existing solutions. There might be other people with similar problems who could profit from the discussion in the thread.
  • Do not ask for or reply with solutions as code, nor in plain text, rather comment explanations and guides. Comments with solutions will be removed and commenters will automatically be banned for a week.
  • No PM help requests or offers. Either ask your questions here and show your code, or you're out of luck. PM help requests or offers will be removed without warning.
  • No piracy! We do neither tolerate requests for pirated material, nor do we allow advocating pirated material (even mentioning that you could download commercial products for free is forbidden) - such content will be removed without warning and the poster will automatically be permanently banned from the subreddit.
  • No resource recommendations/promotions outside of the community resources thread Please post any recommendations and promotions of resources such as courses, websites and videos in the bi-weekly community resource thread.

  • Code posting
  • No screenshots of code!
  • Do not submit executable jar or compressed (zip, rar, 7z, etc.) files!
  • For small bits of code (less than 50 lines in total, single classes only), the default code formatter is fine (one blank line, then 4 spaces before each line).
  • Redditlint is a quick and simple code formatter for reddit code. Copy your code into Redditlint, click Format + Copy, and paste the code in your post (remember to leave an empty line above the code!).
  • Pastebin for programs that consist of a single class only
  • Gist for multi-class programs, or programs that require additional files
  • Github or Bitbucket repositories are also perfectly fine as are other dedicated source code hosting sites.
  • Codiva.io or Ideone for executable code snippets that use only the console
  • Repl.it - online IDE for many different programming languages
  • Google Drive, Dropbox, Mediafire, etc. are not suitable for code posting!

Free Tutorials

  • Derek Banas' Java Playlist
  • Marco Behler's youTube channel
  • Hyperskill is a fairly new resource from Jetbrains (the maker of IntelliJ)
  • Dev.java - Oracle's own Java learning platform

  • Where should I download Java?

    With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.

    If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:

    Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!


    Software downloads

    Official Resources

    Resources

    Programming ideas & Challenges

    Related Subreddits

    /r/learnjava

    165,065 Subscribers

    1

    Help setting up Spring Security

    the project: file (dot) io/G5LISDcFlH7s
    Hi friends, here i have a disaster of a spring security setup. I really dont know what most of it is, ive been studying spring security for a week now and im still very lost. And even the error messages i get i dont really know what they mean (pastebin (dot) com/R10qV46U). Help :(

    1 Comment
    2024/12/02
    10:51 UTC

    33

    Is there any good resource for JAVA and SPRINGBOOT, like there is cherno for C++ ?

    I am a software developer, and my current tech stack includes Node.js, NestJS, and TypeScript. Now, I want to learn Java and Spring Boot. Are there any good free resources that teach Java in-depth? Also, considering I already know C++ and JavaScript/TypeScript, how much time do you think it will take for me to become proficient in Java?

    15 Comments
    2024/12/02
    03:01 UTC

    2

    If you have class that extends from other, that class needs mandatorily to have a constructor ?

    If you have class that extends from other, that class needs mandatorily to have a constructor ?

    3 Comments
    2024/12/01
    23:50 UTC

    5

    Longshot, but can someone help locate a Spring Blog with really good content?

    I believe sometime in the last 2 weeks there was a post on r/java with a link to a blog of someone previewing upcoming SpringBoot 3.4 features and talking briefly about each feature. Other posts on this blog were the person talking in-depth about how Spring loads properties and environment variables. I also believe there was a blog post about the recent Java 24 fixing the green threads issue with IO.

    I was reading this post and was quite surprised at how detailed and informative it was. Miles above and Baeldung or Medium articles I had read on the same subject.

    Unfortunately, I can't find this blog in my browser history, it seems to have been deleted from r/java, and Google's recent changes to search pretty much just pull any searches about SpringBoot 3.4 or the internals of Spring's property loading process into the same 4 or 5 Medium, InfoQ, or Baeldung articles, even when trying to tease out the wording to hit the specifics of the blog in question.

    It seems really hard to find high quality blogs from individual developers that really know their stuff from Google alone.

    Again a longshot, but if anyone knows of a blog (that seems to be written by one developer) separately covering: the recent SB 3.4 update features, Spring property loading, and Java 24 changes to threads then please link it below.

    Worst-case scenario I guess we just get some links to other high quality Java/Spring blogs?

    1 Comment
    2024/12/01
    19:02 UTC

    0

    Button Handler within a function: Local or Global

    Hi,

    I havethe following code. It has a button handler

    Hi,

    I got a program from ChatGPT. It has made a button handler inside the function "CreateBtns()". Kindly tell me is the button handler global or local?

    Following is my code:

    public class CreateBtnProg {
       JFrame frame;
       JButton[] button = new JButton[10];
       JPanel panel;
       String strInp="";
       DoublyLinkedList objDLL;
       public void CreateBtns() {
          frame = new JFrame("Button Example");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(1200, 200); // Increase frame width to fit all buttons
    
          // Set the layout manager for the frame
          frame.setLayout(null); // Use null layout to allow absolute positioning
          buttonController.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                // Action to be performed when the button is clicked
                // Display a message in a dialog box
                //Generate random numbers from 0-9
                Random rand = new Random();
                // Will work for [0 - 9].
                int randVal= rand.nextInt(10);//This will designate the start node from where counting starts
                :
                :
            }
          });
       }
       public static void main(String[] args) {
          CreateBtnProg obj = new CreateBtnProg();
          obj.CreateBtns();
       }
    }

    Zulfi.

    3 Comments
    2024/12/01
    18:05 UTC

    56

    I made a Wordle in Java and I'm proud of myself

    Hi.
    So instead of complaining like I did here. I decided to take action an actually code. I had this idea to make a Wordle in Java, and I did it with some struggle, but I did it.

    I'm a beginner in programming, and I know that some people here will pull their hair off while reading the code, but I'll accept all criticisms from you guys in order to improve.

    Here's the code : https://pastebin.com/8WrDJMfG

    7 Comments
    2024/12/01
    16:50 UTC

    4

    Recommend me resoouces for learing jsp

    I have learned all the basic and other java features but i would like to learn hoe to make apps and java servers but i am got getting proper resources online so i would request You Guys to please recommend me some resources from where i can learn those

    2 Comments
    2024/12/01
    16:07 UTC

    9

    What website should I learn Java on?

    Im a 14 year old male and Im wanting to get into coding what website would give me the best bang for my buck?

    18 Comments
    2024/12/01
    02:38 UTC

    11

    Recommended Java Courses

    Hi, I have a question. I've been learning Java on my own through documentation, yt, practices, and through mooc.fi but when I searched for information I realized that a lot of people recommend Tim Buchalka's Java Masterclass course. Some say it's okay at first and then his explanations go downhill. If any of you have taken it, could you tell me if it's worth it? Or if you have any other courses you recommend, which ones would they be?

    9 Comments
    2024/11/30
    22:21 UTC

    14

    What are the things that should I learn if I want to be a senior java developer? Currently an intermediate java

    Learn Java

    12 Comments
    2024/11/30
    17:20 UTC

    6

    Question regarding hyperskill

    Guys I'm planning to learn springboot from hyper skill. Is it really a good platform to learn from?. It kinda seems a bit complicated for me though but is it really worth spending my time for? I really want to know that coz I only have less time to study some technology and master it. Gotta do a project on it asap.!!

    2 Comments
    2024/11/30
    16:22 UTC

    17

    My Mind is blown and im actually in shock by the discovery of this...

    Is this for real that the Spring Data Mongo repository maps the entities based on the method name!!?

    like you mean i can write List<User> findByLastNameHavingBalls(User) and it will work!!???

    10 Comments
    2024/11/30
    16:20 UTC

    21

    Programming in Java without using the Garbage Collector (Garbage Free Programming)

    This is my first post on the learnjava reddit community so apologies in advance if I'm not following proper etiquete.

    Some of the clients I work for, most of them from the financial industry, use Java for real-time low-latency systems. These are mostly trading systems that cannot afford the overhead of the garbage collector.

    I made a YouTube video (https://www.youtube.com/watch?v=bhzv6lJtuOs) where I discuss this Java programming technique in detail, with an example of a Params class that parses a line containing parameters, for example "aaa 123 bbb" , without producing any garbage. It is basically using Java as a syntax language.

    To make things more fun I also employed the help of our friend ChatGPT :)

    What do you think about this garbage-free approach? Also any feedback/comment about the video would be appreciated. This is my very first video.

    Thanks and Happy Thanksgiving!

    22 Comments
    2024/11/30
    11:56 UTC

    3

    Java JNI vs FFM

    I just compiled my very first JNI DLL. This means that XFrames can soon be used with languages that depend on the JVM. I'd have loved to use Java Foreign Function and Memory, but I couldn't quite figure out how to use it. Know anyone who's used it?

    5 Comments
    2024/11/29
    23:04 UTC

    9

    Is the helsinki mooc the defacto starting place despite being sunsetted?

    I was looking for Java material for beginners and the java mooc came up on some older reddit threads. Looking into it however, it turns out the course was updated recently but replaced entirely by Python.

    The older course is still accessible via the URL for it but it's a little buried on their website now.

    If this isn't the best place to start out anymore, where is?

    17 Comments
    2024/11/29
    20:09 UTC

    0

    Springboot course

    I want youtubers paid springboot course for free. Can anyone provide me please.

    4 Comments
    2024/11/29
    14:52 UTC

    23

    Where I can learn about Java with advanced concepts?

    Hello

    I am looking for good learning resources, which also explain advanced concepts of Java such as interfaces, abstract classes, static/public/private/protected fields/methods, threads, race conditions, instances, data types etc.

    I'm more interested in to reading stuff, I'm not good with online video courses and if possible I would things to be up to date with Java 21.

    Thanks

    21 Comments
    2024/11/29
    14:15 UTC

    2

    ASCII art animation on java

    hello everyone. not so long ago i started learning java. i want to make something in ASCII with infinite loop. "animation". is there any materials for it? thx.

    4 Comments
    2024/11/29
    13:17 UTC

    3

    Hi I'm new to java, what opengl binding or smth that I should use to make a 3d engine

    The title kinda says it all, Im kinda new to java, it's very similar to c# (I modded unity games via bepinex and modifying dll with dnspy) I used lwjgl and it was a pain to use, I was following a tutorial using lwjgl 2 while I was using lwjgl 3, are there any good tutorial(s) for lwjgl 3 or a whole different library

    6 Comments
    2024/11/29
    12:59 UTC

    4

    Am I solving a OOP design problem the correct way?

    /**********************************************************************************
    * (The Account class) Design a class named Account that contains:                 *
    *                                                                                 *
    * ■ A private int data field named id for the account (default 0).                *
    * ■ A private double data field named balance for the account (default 0).        *
    * ■ A private double data field named annualInterestRate that stores the current  *
    *   interest rate (default 0). Assume all accounts have the same interest rate.   *
    * ■ A private Date data field named dateCreated that stores the date when the     *
    *   account was created.                                                          *
    * ■ A no-arg constructor that creates a default account.                          *
    * ■ A constructor that creates an account with the specified id and initial       *
    *   balance.                                                                      *
    * ■ The accessor and mutator methods for id, balance, and annualInterestRate.     *
    * ■ The accessor method for dateCreated.                                          *
    * ■ A method named getMonthlyInterestRate() that returns the monthly              *
    *   interest rate.                                                                *
    * ■ A method named getMonthlyInterest() that returns the monthly interest.        *
    * ■ A method named withdraw that withdraws a specified amount from the            *
    *   account.                                                                      *
    * ■ A method named deposit that deposits a specified amount to the account.       *
    *                                                                                 *
    * Draw the UML diagram for the class and then implement the class. (Hint: The     *
    * method getMonthlyInterest() is to return monthly interest, not the interest     *
    * rate. Monthly interest is balance * monthlyInterestRate. monthlyInterestRate    *
    * is annualInterestRate / 12. Note that annualInterestRate is a percentage,       *
    * e.g., like 4.5%. You need to divide it by 100.)                                 *
    *                                                                                 *
    * Write a test program that creates an Account object with an account ID of 1122, *
    * a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw     *
    * method to withdraw $2,500, use the deposit method to deposit $3,000, and print  *
    * the balance, the monthly interest, and the date when this account was created.  *
    /*********************************************************************************/
    
    
    
    
    
    import java.util.Date;
    
    public class Account {
        private int id;
        private double balance;
        private double annualInterestRate;
    
        Account() {
            id = 0;
            balance = 0;
            annualInterestRate = 0;
        }
    
        Account(int num1, double num2) {
            id = num1;
            balance = num2;
        }
    
        /**
         * setters
         */
        public void setId(int num) {
            id = num;
        }
    
        public void setBalance(double num) {
            balance = num;
        }
    
        public void setAnnualInterestRate(double num) {
            annualInterestRate = num;
        }
    
        /**
         * getters-dateCreated also has a getter
         */
        public int getId() {
            return id;
        }
    
        public double getBalance() {
            return balance;
        }
    
        public double getAnnualInterestRate() {
    
            return annualInterestRate;
        }
    
    
        public double getMonthlyInterest() {
            return (balance * annualInterestRate / 1200);
        }
    
        public Date getDateCreate() {
            return new Date();
        }
    
        /**
         * withdraw method and deposit method
         */
        public void deposit(double num) {
            balance += num;
        }
    
        public void withdraw(double num) {
            if (num > 0 && num < balance) {
                balance -= num;
            }
        }
    
        public static void main(String[] args) {
    
            Account acc1 = new Account();
            Date saveThisDate = acc1.getDateCreate();
            acc1.setId(1122);
            acc1.setBalance(20000);
            acc1.setAnnualInterestRate(4.5);
            acc1.withdraw(2500);
            acc1.deposit(3000);
            // balance
            System.out.println("Balance is " + acc1.getBalance());
            System.out.println("Monthly interest is " + acc1.getMonthlyInterest());
            System.out.println("Date when the account was created " + saveThisDate);
    
        }
    
    }

    I want to ask if I am solving the problems the correct way? Because these problems don't have solutions and are mostly a design problem. Am I designing them correctly?

    7 Comments
    2024/11/29
    07:22 UTC

    1

    How to change the position of a Button in Java

    Hi,

    I have all the buttons in one line. How can I change the position of the "Controller" button in the following code?

    package com.mycompany.createbtnprog;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.FlowLayout;
    /**
     *
     * @author zulfi
     */
    //https://stackoverflow.com/questions/52876701/creating-buttons-but-have-each-button-have-its-own-variable-name/52877094
    public class CreateBtnProg {
        JFrame frame;
        JButton[] button = new JButton[10];
        JPanel panel;
        public static void main(String[] args) {
            CreateBtnProg obj = new CreateBtnProg() ;
            obj.CreateBtns();
        }
        
        public void CreateBtns(){
            frame = new JFrame("Button Example");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(600, 100); // Set the frame size
    
            // Set the layout manager for the frame
            frame.setLayout(new FlowLayout(FlowLayout.LEFT));
    
            // Create a panel to hold the buttons (optional)
            panel = new JPanel();
            panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    
            // Create and add 10 buttons to the panel
            for (int i = 0; i <= 9; i++) {
                button[i] = new JButton("Button " + i);
                panel.add(button[i]);
                
            }
            JButton buttonC = new JButton("Controller" );
            buttonC.setBounds(60, 400, 220, 30);
            panel.add(buttonC);
    
            // Add the panel to the frame
            //button locatiionhttps://stackoverflow.com/questions/16756903/how-to-set-the-location-of-a-button-anywhere-in-your-jframe
            
            frame.add(panel);
    
            // Make the frame visible
            frame.setVisible(true);
        }
    }

    Somebody please guide me.

    Zulfi

    5 Comments
    2024/11/29
    06:13 UTC

    1

    Cannot run the TMCBean Project

    when i try to run the main file the message appears " The screen cannot be set to the number of lines and columns specified." can you anyone tell me whats wrong i'm new to programming.

    1 Comment
    2024/11/29
    05:36 UTC

    2

    DDD - Domain Driven Design - How do you structure your Spring Boot App?

    Hello Everyone,

    As the title says, I am curious how everyone architects their app. I am interested to see how the overall file structure is. Such as do you have three main directories as Infrastructure, Domain, and Application? Do you have it app-based like Django?

    I look forward to seeing what you have!

    1 Comment
    2024/11/29
    05:16 UTC

    1

    Reflection

    Could somebody please explain the reflection concept in java?

    3 Comments
    2024/11/28
    18:22 UTC

    13

    Where to starts aws?

    Can anyone help me learn aws?

    Like where do I start with as a developer?

    There are way to many things to learn about cloud, and I dont want to be a devops engineer and learn all sorts of things, i just want to pickup thing which are important as a developer, and other things i can pickup later if needed.

    PN: My tech stack is Java and I would appreciate if I could get resources related to java so that I can pickup things faster

    r/aws r/java

    9 Comments
    2024/11/28
    14:22 UTC

    4

    Should I make changes in Users database with email or ID?

    I have Users table in database, it has fuilds like: I'd, email(also works as usename), password, name, surname ext. For example user wants to change password (it's already login, I use JWT taken for that), I ask for write old and new passwords, if old password matches that one in database(I don't store row passwords), I just extract email from AuthenticationContestHolder, and change password where email = getted email. Or I need find ID, by email and only then make changes? I also make sure that email is unique

    6 Comments
    2024/11/28
    13:59 UTC

    5

    Is spring professional develop useful and worth it?

    Do you guys have experience with the certification? Is it a benefit or unnecessary? I have been working with spring for the past 5 years and think about doing it to prove on paper that I actually can do it:D

    https://www.broadcom.com/support/education/vmware/certification/spring-certified-pro

    3 Comments
    2024/11/28
    07:27 UTC

    5

    TMC freakin Beans - "Apple could not verify"

    I've spent like 2 hours on this y'all. I followed all of MOOC's instructions on installing TMCBeans. Absolutely everything I do still leads me to "Apple could not verify “tmcbeans.app” is free of malware that may harm your Mac or compromise your privacy." Here's what I've tried:

    1. Going to Finder --> Applications then right clicking on "Open" (x5)
    2. Going to Security --> Privacy & Security, clicking "Open Anyway" (x5) (including opening and closing the lock)
    3. Restarting my laptop
    4. Updating to Sequoia
    5. Uninstalling then reinstalling the app
    6. 1-3 again

    I have tried every recommendation I have seen on this sub and on Google. Absolutely nothing works. I keep getting the same message no matter what I do. My employer wants me to take this course, so I am on my work laptop. I suppose that must be the problem? IT can't figure this out though. Since I'll be completing this at work, I'll need to be able to use my work laptop.

    So... two questions. Anything else I can try? And if not or if nothing else works, have people successfully gone the VS Code route? I followed all of these steps and I'll be honest, I'm already struggling with the fact that the course's expected app is beans and the video/instructions reflect this. I'm a super beginner to programming and boy am I already so discouraged.

    5 Comments
    2024/11/28
    03:03 UTC

    61

    resume worthy java projects for applying for java developer intern/junior roles

    Can you brainstorm? I 've been learning java since last 1 year and idk what sort of projects could be resume worthy. i.e when do I know I am ready to apply and crack the job given a chance at interview.

    21 Comments
    2024/11/28
    02:17 UTC

    13

    How and where did u learn Annotations in java?(beginner)

    Every time I start learning spring I get stuck at annotations parts! Pls suggest tips for learning annotations. List of mostly used annotations would be very helpful thank you.

    13 Comments
    2024/11/27
    14:17 UTC

    Back To Top