/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

    168,212 Subscribers

    1

    Need help with visualising servlet related concepts

    I'm currently learning about Java Servlets, and I'm finding it challenging to visualize how they work. I'm comfortable with the coding aspect, but creating a mental image of how everything fits together is proving difficult. Does anyone have any tips or resources that focus on teaching through visuals?

    2 Comments
    2025/02/02
    01:54 UTC

    2

    When to use inheritance over an interface or vice versa?

    Is it better to just use an interface class or just define methods and put functionality in them in a class with a constructor for example?

    7 Comments
    2025/02/02
    00:53 UTC

    1

    Why Aren’t My "Dynamic Web Module" and "Java" Versions Updating?

    I’m currently learning about Java Servlets and was setting up files to create a simple feedback form when I encountered the error: "The default superclass, 'javax.servlet.http.HttpServlet', according to the project's Dynamic Web Module facet version (2.3), was not found on the Java build path."

    I’m using Eclipse IDE and have tried changing the Dynamic Web Module version (from 2.3 to 6.1) and the Java version (from 1.8 to 22), under project facets, multiple times, but they always revert to their default settings.

    This issue has been occurring since I switched to using a Maven project instead of a standard Dynamic Web Project.

    2 Comments
    2025/02/02
    00:39 UTC

    1

    Logging on with unsigned MacOS app bundled by jpackage

    I'm trying to help out with a java app on Github. Most of the developers don't have Macs so the current implementation on a Mac requires running a script from the command line. Not very user friendly.

    I'm not a java developer, but I was able to get jpackage to work great and I have an app that runs great (after giving it permission since it is unsigned). The problem is that I can not get it to log anywhere. The app is using slf4j.Logger. I've edited the logback.xml file so I can use a separate file to specify where the log should be. When launching from the script on the command line (essentially just executing the .jar) it works fine. I can log alongside the .jar, or in my Library/Application Support/... Once it's all packaged into an app bundle there's nothing. I've given the app Full Disk Access and it still doesn't work. What is needed for it to be able to write to a log?

    I did find that if I run it from the command line inside the bundle (./MyApp.app/Contents/MacOS/MyApp) the log is created. If I just double-click the app, it's not.

    1 Comment
    2025/02/02
    00:18 UTC

    1

    JNativeHook implementation not working in intellij!

    I am trying to use jnativehook for getting my keylogs, but even after I add the jnativehook-2.2.2.jar into File → Project Structure → Modules . It doesn't work. My terminal inside the intellij gives an error "java: package org.jnativehook does not exist" while every method and every import is colored red. I am absolutely new and im not understading what to do, i searched online, watched videos on youtube, tried to get help with chatgpt. still stuck!

    1 Comment
    2025/02/01
    21:08 UTC

    1

    Wants to switch from Support to Development

    Hi all, Working as Support Executive from last 6 months(joined as freshee) Now wants to switch to Development specially in Java development What should I follow to crack interviews and what should be my approach? Please do share usefull tips

    1 Comment
    2025/02/01
    20:31 UTC

    3

    hi bros i am new here and learning java , i want a help , any body knows best visualizer for viewing the java code in the visualizer ?

    hi bros i am new here and learning java , i want a help , any body knows best visualizer for viewing the java code in the visualizer ?

    12 Comments
    2025/02/01
    14:12 UTC

    142

    Most watched Spring Boot course on Udemy is again temporarily free

    Edit: Its over

    https://x.com/luv2codetv/status/1885675739141349795

    (I'm not affiliated or related with this channel)

    39 Comments
    2025/02/01
    13:16 UTC

    7

    need help

    I'm currently learning java and having a hard time. I'm currently learning METHODS, CONSTRUCTOR, AND MULTI DIMENTIONAL ARRAYS. any advice will be appreciated

    4 Comments
    2025/02/01
    12:41 UTC

    7

    What courses/certificates would it be interesting to take as a Java developer?

    I have experience with Java. But I want to have courses/certificates to have more credibility with companie

    6 Comments
    2025/01/31
    17:26 UTC

    4

    Learn Java

    Hi guys,

    I'm pretty experienced with python already, been learning it for quite some time and I want to start learning java now. What's the best resource, like course or video to follow for someone who already knows programming, but a different language?

    7 Comments
    2025/01/31
    11:15 UTC

    7

    Websockets - resources to learn

    I don't seem to find much resources on building web apps with websockets using spring boot while there are many free tutorials available for ws with node. Looking for resources and suggestions.

    6 Comments
    2025/01/31
    01:48 UTC

    1

    Part04_23.CreatingANewFile on VS Code

    Hello Java Learners,

    I'm encountering an issue with the MOOC Part04_23.CreatingANewFile exercise. I've been using VS Code without any issues until now, but this simple exercise is causing me some trouble.

    Here's what happens: I can successfully create the file "file.txt" using VS Code (I can even see it located into the right folder when using Windows Explorer - the root folder containing the folder src and the file pom.xml), write "Hello, world!" into it , and when I run the TMC tests, I get the following success message:

    Points: 100.00%

    • PASS: CreatingANewFileTest fileExists
    • PASS: CreatingANewFileTest containsTextHelloWorld

    However, when I try to submit the exercise to the server, I receive this message instead:

    Points: 0.00%

    • FAIL: CreatingANewFileTest fileExists AssertionError
    • FAIL: CreatingANewFileTest containsTextHelloWorld AssertionError

    Has anyone encountered a similar issue? Any advice on what might be going wrong would be greatly appreciated!

    5 Comments
    2025/01/31
    00:08 UTC

    2

    Need help continuously updating a char array

    I don't have my source code, as it is at work. So, I'll try to mimic what I remember from it. I don't have lots of Java experience so please take it easy on me. I've added lines to make it easier to read.

    1 char[] simpleArr = formattedTime.toCharArray();    
    2 timer.scheduleAtFixedRate(new TimerTask() { 
    3 @ Override 
    4 public void run () { 
    5        char[] simpleArr = formattedTime.toCharArray(); 
    6 } 
    7 }, 5000, 10000); 
    8 while(true) { 
    9 if (Arrays.equals(simpleArr, anotherSimpleArr)) { 
    10 //do this command 
    11 }

    This is essentially what I'm trying to do, but I'm getting an error that simpleArr can't be enclosed in the timer method. I've tried moving line 1 around as well as moving line 5 around and can't get it to work. If I'm making this too complicated, please let me know. My issue is that I don't know how else to go about constantly updating the simpleArr, but I have to keep it updating basically forever. Thanks to anyone that is willing to help!

    6 Comments
    2025/01/30
    23:47 UTC

    6

    Can you recommend resources to learn about JUnit and testing?

    Articles, books, sites.

    6 Comments
    2025/01/30
    19:04 UTC

    2

    how do i create join query in springboot jpa?

    i am trying to create a inner join query using Query annotation but i am keep getting this error where it says the query is not being generated what should i do?

    2 Comments
    2025/01/30
    14:57 UTC

    45

    Are lambda expressions worth learning? Are they widely used?

    I've been 4 months now in my programming course, mainly Java, and professor told us not to bother with them and that they are deprecated. Idk, at first glance they seem to be more optimal sintaxys-wise and all. What's the opinion of the veterans on this regard?

    40 Comments
    2025/01/30
    11:02 UTC

    8

    Java learning next step question

    I recently finished a Java MOOC from the University of Helsinki followed by some projects like: checkers, FlappyBird, Todoapp made with JavaFX. I came across this course 6.005.1x Software Construction in Java from MIT and I wonder if it is worth it and relevant. Does anyone have some experience with this resource ? I was thinking about this course to deepen my Java knowledge.

    4 Comments
    2025/01/30
    09:27 UTC

    7

    Is Swing+JxBrowser the best of both worlds?

    I am an app developer, and I also write desktop apps. Most of the time, I use either Electron or Tauri, because I thought certain kinds of user interaction patterns are impossible in Swing, which I have use to build mostly monitoring UIs up until now. But recently, I was made aware of JxBrowser and... isn't this amazing? What exactly are drawbacks and what is keeping me from building a Swing application and then add, e.g., complex web mapping using OpenLayers?

    EDIT Not limited to JxBrowser, any WebView embedding in Swing is intended.

    1 Comment
    2025/01/30
    07:47 UTC

    9

    Java, Spring Boot evergreen tech but no opportunities for freshers

    Hi, I am passout of 2023 class with Electrical Engineering degree. I wanted to make a career in the tech. And started to learn Java, Spring Boot from 2024, after I didn't get qualified in gate ee. I am looking for opportunities and its been over a year. And still no one gives a positive reply for my 100s jobs applications every month.

    Ps I can build java full stack applications using Spring Boot and React. I can dm my portfolio if you are interested in hiring or know someone.

    14 Comments
    2025/01/30
    03:47 UTC

    3

    How can I implement a notification feature in a Spring Boot application

    Requirement

    1. Roles: Teachers and Students.
    2. Trigger: When a new alarm is created in an external system (Thingsboard), generate a notification for all students linked to that alarm.
    • Alarm: alarms of events

    • Notification: what students will see in a mobile App

    • No control over the Alarm schema/database (must use Thingsboard’s REST API to fetch alarms).

    1. Constraints:
      • No control over the Alarm schema/database (must use Thingsboard’s REST API to fetch alarms).
    2. Key Goals:
      • Map alarms to students (how?).
      • I need to create a notification table because alarm is for a specific event while notification is for each student

    I am thinking to create a notification table like

    {
      "notificationId": "UUID",
      "studentId": "UUID", // Reference to the student
      "alarmId": "UUID",   // Reference to the alarm from Thingsboard
      "message": "String", // Notification message
      "isRead": "Boolean", // Whether the notification is read
      "createdAt": "Timestamp"
    }

    Do you guys think that makes sense

    1 Comment
    2025/01/29
    23:45 UTC

    2

    Docker help

    I have this docker compose:

    services:
    api_service:
    build: .
    restart: always
    ports:
    - "8080:8080"
    networks:
    - springapimysql-net
    environment:
    SPRING_DATASOURCE_URL: jdbc:mysql://mysqldb:3307/banking
    SPRING_DATASOURCE_USERNAME: Nazar
    SPRING_DATASOURCE_PASSWORD: strong_password
    depends_on:
    mysqldb:
    condition: service_healthy
    volumes:
    - .m2:/root/.m2

    mysqldb:
    image: "mysql:8.0"
    restart: always
    ports:
    - "3307:3306"
    networks:
    - springapimysql-net
    environment:
    MYSQL_DATABASE: banking
    MYSQL_USER: myUser
    MYSQL_PASSWORD: strong_password
    MYSQL_ROOT_PASSWORD: even_stronger_password
    healthcheck:
    test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
    interval: 10s
    retries: 5

    networks:
      springapimysql-net:
    version: '3.8'

    and this application.properties

    spring.datasource.url=jdbc:mysql://localhost:3306/banking?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
    spring.datasource.username=myUser
    spring.datasource.password=strong_password
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

    When I try to run docker compose both my imagies running correctly, but then I open logs for the service and it could not connect to db, so nothing actually wwork, how fix that, help please

    6 Comments
    2025/01/29
    23:27 UTC

    1

    Suggestion

    I have worked on projects that only focus on the backend, with no frontend development. should i mention that project in resume (spring boot) ? or build frontend also ? And how should i prepare for interview ? i am a fresher. please guide me .

    3 Comments
    2025/01/29
    18:12 UTC

    7

    Hello everyone, Need Genuine help if anyone want to learn Java along or if anyone can help me teach Java backend. I already have job and someone managing it.

    I have a job and willing to learn Java backend, I don't know where to start and what to do. Have tried 1 or 2 times but after a week or starting failed to continue and then continue to work with help or someone. Please don't judge on this if anyone can help me learn Java I am ready to reward them good.

    15 Comments
    2025/01/29
    17:53 UTC

    1

    Spring Boot r2dbc enum error - org.springframework.r2dbc.BadSqlGrammarException

    I have been working on creating a chat_module application with Reactive programming - spring boot 3.4.1, postgres-r2dbc, and mongo reactive.
    I have tried to add every detail in the below gist.

    https://gist.github.com/Together-Java-Bot/a05418d75e2f7cca670c9492d5942b1c

    1 Comment
    2025/01/29
    09:44 UTC

    6

    How to check whether string is numeric in java without using exceptions?

    21 Comments
    2025/01/29
    08:21 UTC

    9

    Site to Learn And Practice Java?

    I've been looking for some sites to learn and practice java at home, to help build some consistency in my work. I've used Coddy.tech and almost gone through the course but it costs money and you need an account, are there any free options that don't require an account? Or are at least free for now.

    4 Comments
    2025/01/29
    04:36 UTC

    3

    Understanding codebases

    Hello everyone. I've been working with java for a year now. Mainly spring boot apis. I want to understand java better, project structures (large ones) I want to understand Jenkins. Is a piece of software I'll start using in some time and a very interesting one.

    I cloned the repo, opened it up in inteliij and I could not understand how the project was structured, how maven and pom works, how everything becomes a single .war and where to begin.

    I can understand java code, but this has been really hard for me.

    Any advice? How to understand something like this? where to begin? how to learn this big project structures?

    3 Comments
    2025/01/28
    23:36 UTC

    1

    New but not new seeking Advice.

    So I'm start off saying I haven't touched programming in years after being told many times. I'm overqualified for etc jobs. I gave up after a while of searching. But I recently picked up the udemy java course by tim bulkchalka and web development by blue time studios and a few books. I'm trying to pace myself and basically make things that I enjoy while relearning the core basics. I wanna make games/mods in the long run and see where it takes me.

    4 Comments
    2025/01/28
    23:24 UTC

    1

    AdvancedAstrology Mooc FI

    Hello everybody,

    I am currently doing the mooc trying to learn java. In Part 2 the exercise AdvancedAstrology, espacially part 2 and 3 of the exercise, stunlocked me. I couldnt find a solution in my brain. So as I have a fulltime job, not related to coding, I decided to look on this reddit for some help. I tried to solve the exercise for around 3-5 hours I would say.

    Is it okay to look stuff up if you hit a hard wall after trying for a while our would you say try it until you found the solution without any help? I would love some opinions to this from newbies & pros alike.

    Thanks in Advance!

    2 Comments
    2025/01/28
    10:58 UTC

    Back To Top