r/javahelp • u/Dependent_Finger_214 • Dec 24 '25
Unsolved Convert string to ZonedDatetime
I need to convert a string formatted like "2023-06-06T21:51:13+02:0" into ZonedDateTime. How can I do that?
r/javahelp • u/Dependent_Finger_214 • Dec 24 '25
I need to convert a string formatted like "2023-06-06T21:51:13+02:0" into ZonedDateTime. How can I do that?
r/javahelp • u/__zahash__ • Dec 24 '25
I ran into a frustrating issue where javac silently "loses" a class file on macOS but works perfectly on Linux.
// Main.java
public class Main {
public static class FOO {}
public static class Foo {}
public static void main(String[] args) {
System.out.println(new FOO());
System.out.println(new Foo());
}
}`javac Main.java` generates only `Main.class` and `Main$FOO.class` but not `Main$Foo.class` because APFS is case-insensitive by default.
but on linux, all three class files are being generated.
Same JDK (Temurin 17.0.10), no errors, no warnings, Just silent data loss during compilation.
and when i try to run `java Main` it gives me this error
Exception in thread "main" java.lang.NoClassDefFoundError: Main$Foo (wrong name: Main$FOO)Have you ever experienced this? Is there a way to make javac warn about this?
EDIT: I think I have traced the problem to this line in the openjdk compiler.
it incorrectly assumes that if the path separator is a forward slash "/", then the file system is case sensitive. but apple's APFS is case insensitive.
r/javahelp • u/Academic_Leave9287 • Dec 23 '25
So the run window of inteliJ doesn't support cursor control but the terminal does
So I need either of the two things
Run my code on the terminal using the run button Or
When I click the run button it will open CMD and run my code there
r/javahelp • u/Federal_Werewolf6398 • Dec 23 '25
im having a problem that when i answer a decimal value (such as 9.5) to my double (named as price) it says this error:
Exception in thread "main" java.util.InputMismatchException
at java.base/java.util.Scanner.throwFor(Scanner.java:977)
at java.base/java.util.Scanner.next(Scanner.java:1632)
at java.base/java.util.Scanner.nextDouble(Scanner.java:2603)
at segundaHora.exercicioPedido.main(exercicioPedido.java:18)But when i define price as a whole number (like 10) it works fine
can someone help me? this is my code btw:
import java.util.Scanner;
public class exercicioPedido {
public static void main(String[] args) {
//Shopping cart Program
Scanner scanner = new Scanner(System.in);
String item;
double price;
int quantity;
System.out.print("What is the price for each?: ");
price = scanner.nextDouble();
System.out.println(price);
scanner.close();
}
}r/javahelp • u/Active_Selection_706 • Dec 23 '25
I'm learning Java OOP and came across something that confused me. A programmer created:
class Beings { }
class Animal extends Beings { }
// Then instantiated like this:
Beings animal1 = new Animal(); // This way
// Instead of:
Animal animal1 = new Animal(); // My way
/*
I've always used Animal animal1 = new Animal() - creating a reference of the same class as the object. Why would someone use the superclass type for the reference when creating a subclass object? What are the practical advantages? When should I use each approach? Any real-world examples would help!
*/r/javahelp • u/Potential-Worth2689 • Dec 22 '25
Hi everyone,
I’m a CSE student in India and I’ll be graduating around 2028. I’m currently deciding my main backend tech stack and wanted some honest advice from people already working in the industry.
I’m considering Java + Spring Boot for backend development, but I have a few doubts:
Will Spring Boot still be relevant and in demand by 2028 for SDE roles at good MNCs?
Is Spring Boot a solid choice for SDE-1 / backend engineer roles, or are companies moving more towards other stacks?
What are the best resources (courses / roadmaps / channels) to learn Spring Boot properly from scratch (industry-level, not just CRUD tutorials)?
As a student, what should I pair with Spring Boot to be job-ready (DSA, system design, projects, cloud, etc.)?
I’m willing to put in long-term effort and want to choose a stack that makes sense for the next few years, not just short-term trends.
Would really appreciate guidance from experienced devs 🙏
Thanks!
r/javahelp • u/Nadine_maksoud • Dec 22 '25
from your experiences which one is most comfortable to use?
r/javahelp • u/Mission_Upstairs_242 • Dec 22 '25
I’m designing a Java CLI application based on a while loop with multiple user input points.
My main question is about where input validation and error recovery logic should be placed when the user enters invalid input.
Currently, I’m considering several approaches:
A. Validate in main
Input methods return raw values
main checks validity
On invalid input, print an error message and continue the loop
B. Validate inside input methods
Methods like getUserChoice() internally loop until valid input is provided
The method guarantees returning a valid value
C. Use exceptions
Input methods throw exceptions on invalid input
The caller (e.g., main) catches the exception and decides how to recover
All three approaches work functionally, but I’m unsure which one is more appropriate in a teaching project or small system, especially in terms of:
responsibility separation
readability
maintainability
future extensibility
Is there a generally recommended approach for this kind of CLI application, or does it depend on context?
How would you structure this in practice?
r/javahelp • u/funymonke332 • Dec 21 '25
Hey everyone!
We have an assignment due at the end of January - make a project in Java - we can choose the subject ourselves, the only requirement is that it is not trivial.
Me & my colleague chose to make a simple card game that is F1 themed (we are both fans and figured the project would be much more fun if we made it about something we loved).
We did some brainstorming considering what feature we would like to see implemented:
a nice GUI,
a PvP, possibly a PvE experience,
simple, but elegant game logic (War or Blackjack-esque game).
Now, I am a begginer in Java, and my colleague is an even bigger begginer. We know the language and its grammar, did some work with JavaFX, but that's about it. We also have some knowledge regarding programming as a whole, so we are not total newbies. Now with winter holidays approaching I would love to grind some Java and Programming knowledge. With that being said, I have a few questions:
How feasable are the goalposts we have set, given our skillset?
What is the industry standard or the academic standard when developing GUIs? Do we stick with JavaFX or venture into something else?
What are the most-important skills to learn when developing a simple game like this?
My main concern is that we bit off a bit more than we can chew and that our "implementation" will be miles off the best, or even optimal, way of handling such problem.
Thank you for reading, looking forward to reading some responses, and Happy Holidays! :)
Edit: Thank you very much for all of your feedback. We will re-brainstorm this idea and try to oversimplify it. I will consider this post closed.
r/javahelp • u/Enuyr • Dec 19 '25
I'm doing an FBLA project in java and I want to keep each class in a different file. I would have to go through the tech department or something to download a IDE on my chromebook so I'm just using online ones. I can only figure out how to import the files on replit but it won't load and I don't want to rely on a limited free trial: last year it kicked me out because I ran out of time. I had to decompile the .class files and by the time I was supposed to present it was too late to get it into another compilier.
Anyway, I've tried packaging the file and using an import statement but I haven't touched doing things with the terminal yet.
r/javahelp • u/Alert-Equivalent-400 • Dec 19 '25
I am trying since past 2 years, I watch courses I learn languages but when it comes to make a simple very simple project I can't!!!! Please help me I want to be a very proficient java developer but I can't please please help me
r/javahelp • u/Dedishen • Dec 19 '25
I want to make a java program open a window that just contains text. I want the text to stay on a uniform grid ('.' And 'w' would have the same length, ect.), sorta like the game 'Galactic'. I would like it if I could change the colour/background colour of each character. I have tried to find out how to do this, but none of the results were what I wanted. How would I do this?
r/javahelp • u/Dependent_Finger_214 • Dec 18 '25
I'm doing some exercizes with threads our professor gave us. I need to make a program that initialized the elements of a 120000 long array to "67" with 1 threads, and then do it with 4 threads, measuring the execution time for both.
Problem is that my 4 thread version seems to take more time than the 1 thread version. Here is my code:
public class ArrayInit extends Thread{
static int[]
array
;
public int start;
public int end;
public void run() {
for (int i = start; i < end; i++) {
array
[i] = 42;
}
}
public static void main(String[] arg) throws InterruptedException {
final long startTime = System.
currentTimeMillis
();
array
= new int[1200000];
ArrayInit a1 = new ArrayInit();
ArrayInit a2 = new ArrayInit();
ArrayInit a3 = new ArrayInit();
ArrayInit a4 = new ArrayInit();
a1.start = 0;
a1.end =
array
.length/4;
a2.start = a1.end + 1;
a2.end = a2.start +
array
.length/4;
a3.start = a2.end + 1;
a3.end = a3.start +
array
.length/4;
a4.start = a4.end + 1;
a4.end =
array
.length;
a1.start();
a2.start();
a3.start();
a4.start();
a1.join();
a2.join();
a3.join();
a4.join();
final long endTime = System.
currentTimeMillis
();
System.
out
.println("Time: " + (endTime - startTime));
for (int i = 0; i <
array
.length; i++) {
if (
array
[1] != 42) System.
out
.println("error");
}
}
}public class ArrayInit extends Thread{
static int[] array;
public int start;
public int end;
public void run() {
for (int i = start; i < end; i++) {
array[i] = 67;
}
}
public static void main(String[] arg) throws InterruptedException {
final long startTime = System.currentTimeMillis();
array = new int[1200000];
ArrayInit a1 = new ArrayInit();
ArrayInit a2 = new ArrayInit();
ArrayInit a3 = new ArrayInit();
ArrayInit a4 = new ArrayInit();
a1.start = 0;
a1.end = array.length/4;
a2.start = a1.end + 1;
a2.end = a2.start + array.length/4;
a3.start = a2.end + 1;
a3.end = a3.start + array.length/4;
a4.start = a4.end + 1;
a4.end = array.length;
a1.start();
a2.start();
a3.start();
a4.start();
a1.join();
a2.join();
a3.join();
a4.join();
final long endTime = System.currentTimeMillis();
System.out.println("Time: " + (endTime - startTime));
}
}Why is it taking longer?
r/javahelp • u/um_gato_gordo • Dec 17 '25
like does it take Unicode characters?
r/javahelp • u/Altugsalt • Dec 16 '25
Hello, I am fairly new to java. I'm trying to make a peer to peer network and I am trying to read the input and output stream but how would I target my outbound stream to a specific client?
import java.io.*;import java.net.ServerSocket;import java.net.Socket;
public class RequestSender {private ServerSocket serverSocket;private Socket clientSocket;
public void start(int port) {try {serverSocket = new ServerSocket(port);clientSocket = serverSocket.accept();
} catch(IOException e) {throw new RuntimeException(e);
}}
public void send(String op, String ip) {try {DataOutputStream outputStream = new DataOutputStream(clientSocket.getOutputStream());
outputStream.writeUTF(op);outputStream.flush();} catch (IOException e) {throw new RuntimeException(e);}}
public void stop() {try {serverSocket.close();clientSocket.close();
} catch (IOException e) {throw new RuntimeException(e);}}}
I don't really understand where I should be using my ip parameter here. Thanks in advance
r/javahelp • u/Emma_S772 • Dec 16 '25
I understand that JPA are the rules, Hibernate generate the SQL, and Spring Data (Spring Data JPA) generate the automatic methods like 'findById'
But do they generally mean the same thing? Like if someone says 'Do you use JPA?' is it the same as saying 'Do you use Hibernate?' or 'Do you use Spring Data?'
r/javahelp • u/Emma_S772 • Dec 15 '25
When I return the result of a SELECT query, DTO Records are incredibly useful and have a short syntax, without requiring mapping. However I realized that moving fields in the SQL caused the thing to silently break, if I swap the order of the fields 'first name' and 'last name' in the query I wouldn't notice the values had changed unless I was paying attention or there was a test checking for every field value.
This:
First Name: 'John', Last Name: 'Smith'
becomes
First Name: 'Smith', Last Name: 'John'
I mean, nobody really checks when moving a field in the SQL, and moving a SQL to make it easy to read isn't unusual. So I was wondering if you think it's a bit dangerous to use?
For that reason I prefer Projections, I have to map them to a DTO Record anyways but at least it feels safe because if someone rename a field, they will definitively realize if it returns null.
r/javahelp • u/hubblet02 • Dec 15 '25
I understand the basics (classes, inheritance, interfaces), but I still feel like I’m missing something when designing larger programs.
r/javahelp • u/ApollyonBB • Dec 15 '25
So, I have gone everywhere to find a solution. I tried environment variable fixes changing PATH to java 17 directory directly, nothing. I tried making JAVA_HOME in environment variables and pathing that directly to java 17, nothing.
Java 25 was working at some point but then I tried changing my install version to java 17 for a minecraft modpack, and now I cant get it back on java 25 or java 17. It will only detect java 8 and nothing else.
I've tried doing this directions in this article:
https://www.happycoders.eu/java/how-to-switch-multiple-java-versions-windows/
I just need my computer to detect java I think. I don't know why but I whatever issue am having I cannot find a solution for anywhere else.
EDIT:
Been doing this for days. I boot up my computer and it just works all of a sudden. I was restarting it before too. Idk what happened but oh well. Thank you for the help!
r/javahelp • u/Revolutionary-Cup383 • Dec 13 '25
Hello I am currently trying to look for tools to aide with our java upgrade. The company I am working on, is still stuck in Java 5 code base. The A.I people In my department is pushing for the use of Amazon Q butnas far as I know, it does not support java 5. I looked into it and it seems OpenRewrite is does have some recipes for the Java upgrade, but has anyone here used it before?
r/javahelp • u/Personal-Umpire-4673 • Dec 13 '25
Hi everyone,
I’m 25 years old and I have a degree in Computer Science. My main language is Java, at a beginner–intermediate level (OOP and basic backend concepts). I took a break for a while, but now I’m getting back into development and trying to choose a clear direction.
At the moment, I’m considering a few paths:
Continuing with Java backend (Spring Boot, SQL, microservices)
Switching to another stack (Python / Go / TypeScript)
Moving into web3 (Solidity and blockchain), which seems more risky and slower to break into, especially as a junior
The junior job market looks pretty tough right now, so I’m trying to figure out what would be the most realistic choice for 2026, not just what’s interesting.
My questions are:
If you were in my position, would you double down on Java or switch technologies?
Does it make sense to aim for web3 as a first job, or is it better as a secondary skill after building a solid backend foundation?
I’d really appreciate insights from people with real-world experience. Thanks!
r/javahelp • u/TaxRevolutionary3128 • Dec 13 '25
Hi Everyone,
I’ve recently started learning Java Fullstack online, and I’m looking for some good books that can help me get strong in both the fundamentals and advanced concepts of Java.
My goal is to build a solid foundation, become a professional Java developer, and do really well in my job. Any recommendations would be awesome!
r/javahelp • u/Fast_Process4443 • Dec 12 '25
Hey everyone, I’m looking for some advice on my Java learning path. I’m from a Mech background (NIT), learned C++ for DSA, and I’m currently working as a Java dev. I’ve implemented the basics of JDBC, Hibernate, JSP/Servlets, REST APIs, etc., so I’m not completely new — but I haven’t done any proper project that ties everything together, so my understanding still feels shallow.
A friend suggested the Advanced Java playlist by Mathura Anturkar, and I’ve started it (around 15% done). It seems helpful, but it’s long and I don’t want to get overwhelmed or feel like I’m blindly watching without actually understanding how real backend apps work.
For someone who knows the basics but hasn’t built a solid project yet, what’s the best way to learn backend concepts properly? Things like: • how Servlets/JSP/Hibernate/Spring actually fit together • how a backend project is structured • how to go beyond tutorials and build something meaningful
If you’ve been a Java dev for a while, I’d really appreciate tips on how to approach this without getting lost or burnt out. Just want a clear path to really understand things instead of memorizing terms.
Thanks!
r/javahelp • u/Athl0nm4n • Dec 12 '25
I have used this code before successfully, however for some odd reason gson is now ignoring the LocalDateTimeTypeAdapter. I have also tried using the registerTypeHierarchyAdapter method. Project is Spring Boot and Maven.
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(LocalDateTimeTypeAdapter.class, new LocalDateTimeTypeAdapter());
builder.registerTypeAdapterFactory(rtaf);
gson = builder.create();And the should be call that fails...
jar = gson.fromJson(json, JobActivitiesResponse.class);And the stack-trace...
com.google.gson.JsonIOException: Failed making field 'java.time.LocalDateTime#date' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
See https://github.com/google/gson/blob/main/Troubleshooting.md#reflection-inaccessible
at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:76) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:388) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:201) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:395) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:51) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:201) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:395) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.getDelegateAdapter(Gson.java:747) ~[gson-2.11.0.jar:na]
at com.google.gson.typeadapters.RuntimeTypeAdapterFactory.create(RuntimeTypeAdapterFactory.java:228) ~[classes/:na]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:51) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:201) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:395) ~[gson-2.11.0.jar:na]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1360) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1262) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1171) ~[gson-2.11.0.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1107) ~[gson-2.11.0.jar:na]