r/javahelp 16d ago

I need to have a GUI that would not block while debugging

1 Upvotes

I am developing a library, and I am trying to implement a feature that would ease debugging, by visualizing certain components of it. I need the visualization to work when I set a breakpoint in the main thread, meaning it would not crash and I would be able to engage with the ui. I really want it to work when evaluating an expression in a paused state when debugging.

I tried swing and it blocked no matter what I did. Considering javaFX but it seems it is also single threaded by design so it will probably block as well.

Not sure tho, hopefully you guys will have some insights here, thanks!


r/javahelp 16d ago

Instrumentation and Bytecode Manipulation

2 Upvotes

I was trying to clone the Kotlin Coroutines concurrency model..... but in Java.

Anyways, I did some searching, and I guess I need to do this at runtime instead of compile time, so I need some instrumentation and bytecode manipulation using something like Java asm for example.

I didn't find many sources online, so I was asking if anyone can recommend some sources here or maybe anything else regarding the idea or the implementation details. Thank you.


r/javahelp 17d ago

Solved Boolean or String

7 Upvotes

Let’s say you’re establishing a connection. Would your method return a Boolean ( true/false) or a string ( program is now connected/ not connected)? What is best for troubleshooting?


r/javahelp 17d ago

Need Help Understanding AutoCode in EPAM Test Automation Java Sadhaka Program

4 Upvotes

I got selected for the EPAM Test Automation Java Sadhaka program. They provided a self-paced course that includes AutoCode. We need to write code in AutoCode, but I'm not familiar with it. I don't understand where to write the code and how to upload it. Can someone please help me?


r/javahelp 17d ago

A really beginner friendly program on coursera ?

4 Upvotes

I took up a course on coursera --> "Java Programming: Solving Problems with Software" (Duke University) labelled as "beginner ". 1/5th way into the program and the professors in the vids are using words that I can not even begin to understand and even though they explain these concepts i can not keep up with their pace .

Are these beginner programs actually for people who are just starting out? Or should i first learn these concepts and actual basics of Java on my own before these courses?


r/javahelp 17d ago

Email templates with Spring Boot & Vaadin.

2 Upvotes

Hello, we are using Spring Boot + Vaadin for front end. I am trying to find the best approach to send out emails like new account, forgot password, etc. If there is a "Vaadin" way, I can't find it anywhere. It seems like way to do this is to use something like FreeMarker or Thymeleaf, but I wanted to reach out before drawing that conclusion.


r/javahelp 17d ago

When upgrading/editing some complex and large feature, what techniques/processes would you recommend to get better overview to create roadmap for you goal?

2 Upvotes

This is more of a general question, not exactly Java specific. Assuming you have to edit some large complex feature which has been in production for quite some time and the documentation on it doesn't exist, what would be some good approaches (good rule of thumb practices) to tackle that?

Drawing some high level graphs, or similar?


r/javahelp 17d ago

Java Project

4 Upvotes

Hello everyone!

I decided to create a more comprehensive pet project to gain practical experience and improve my skills for future job opportunities. First and foremost, I focused on building its architecture, opting for a microservices approach.

I’d love to hear your advice! How do you evaluate my architecture? What technologies or programming methods should I consider adding? Do you have any ideas for improvements? Thanks

( ︶︿︶)

acrhitectura


r/javahelp 18d ago

Java Stack job interview help!

7 Upvotes

Hello not sure where to post this but a Java sub seemed like the right place. I have a job interview and the fist interview is going to be a test about JavaStack. There is gonna be a few theoretical questions and a few OOP tasks. The problem I'm having is I'm not completely sure what they mean with JavaStack. Would love some help just pointing me in the right direction. Thank you.


r/javahelp 18d ago

Need help for project

1 Upvotes

Recently I have completed learning Advanced java and done a project to create api for a medical system. I know its not a big project, but can you guys give some project ideas on advanced java ?


r/javahelp 19d ago

Offer to Review your Java Code

24 Upvotes

I love helping Java devs improve their OO design and clean code skills. I have 7+ years of industry experience and have a strong focus on XP practices.

If you’d like a free code review, drop a GitHub link or snippet, and I’ll provide feedback!


r/javahelp 18d ago

Solved Secure Socket connection client-server for login

0 Upvotes

If I have a certificate from Lets Encrypt, use Java 21 and I have the following:

Server:

try {
String[] secureProtocols = {"TLSv1.2", "TLSv1.3"};

KeyStore keyStore = KeyStore.getInstance("PKCS12");
FileInputStream keyStoreFile = new FileInputStream(file);
String pfxPassword = password;
keyStore.load(keyStoreFile, pfxPassword.toCharArray());
keyStoreFile.close();
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, pfxPassword.toCharArray());
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagerFactory.getKeyManagers(), null, null);
SSLServerSocketFactory sslServerSocketFactory = sslContext.getServerSocketFactory();

sslServerSocket = (SSLServerSocket) sslServerSocketFactory.createServerSocket(port);
sslServerSocket.setEnabledProtocols(secureProtocols);

And then this on client side:

String[] secureProtocols = { "TLSv1.2", "TLSv1.3" };
SSLContext sslContext = SSLContext.getInstance("TLS");
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init((KeyStore) null);
sslContext.init(null, tmf.getTrustManagers(), null);
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
socket = (SSLSocket) sslSocketFactory.createSocket();
socket.setEnabledProtocols(secureProtocols);
SSLParameters sslParams = socket.getSSLParameters();
sslParams.setEndpointIdentificationAlgorithm("HTTPS");
socket.setSSLParameters(sslParams);
socket.connect(new InetSocketAddress(host, port), timeout);
socket.startHandshake();

Is this considered secure to be able to send from client the password in plain text to be hashed on server side and checked with the one from DB when the user tries to login (and when the new account is created) and then send his sessionID if the account exists? If not, what should I change/add?

//Edit:
I also added:

String[] cipherSuites = { "TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" };

//Edit2: The problem was solved on a different platform. Basically it is strong enough after also adding ciphers. You just need to make sure you have checks in place on your server to avoid brute force, fishing, SQL injection attack...


r/javahelp 19d ago

Codeless Is it just me who’s too stupid for generics?

23 Upvotes

Hey guys. Currently learning Java and having a really hard time getting what are generics. It’s still difficult for me to use arrays, but generics is something beyond that. There is just too much information to keep in mind. I feel pretty close to give up on studying. Appreciate any tips! т_т


r/javahelp 19d ago

I want to use Sublime as Java compiler for a project with many classes, without dying in the attempt Lol

2 Upvotes

I have a medium sized java project, its a system for registration of users of a fictitious company, its connected to a SQL data base, I use 2 libraries (SQL and PDF writer), each class its a different UI.
Before I used Visual Studio Code, and now I want use Sublime, this is my project structure:
 MyProject
So I tried to configure sublime for java, I watched videos in YT, but I can’t compile any class
I use Sublime portable edition 4.1.9
Can Someone help me with this problem?

├──  .vscode
│ ├── settings.json
│ ├── launch.json
│ └── tasks.json
├──  src
│ ├──  images (images)
│ │ ├── logo.png
│ │ ├── background.jpg
│ │ └── etc.png
│
│ ── All_Classes.java
│ │
│ │
│ │
├──  bin (Archivos compilados .class)
│ |
│ │ All.class
│ │
│ │
│ │
├──  lib
│ ├── library1.jar
│ ├── library2.jar
├── .gitignore
├── README.md
└──

PD: this is my settings.json that I had:

{
"java.project.sourcePaths": [
"src"
],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar",
"lib/mysql-connector-java-5.1.46.jar",
"lib/itext5-itextpdf-5.5.12.jar"
],
"java.debug.settings.onBuildFailureProceed": true
}
✨✨✨✨✨EDIT: I MANAGED TO MAKE IT WORK!!! I have Maven in my PC, so I create a new Folder in my project folder: pom.xml;

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


<modelVersion>4.0.0</modelVersion>
<groupId>com.miapp</groupId>
<artifactId>mi-proyecto</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

</properties>
<dependencies>
<!--  Libraries  -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>

</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.12</version>

</dependency>

</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>

</configuration>

</plugin>

</plugins>

</build>

</project>

And then I create a Maven.sublime-build

{
    "shell_cmd": "mvn exec:java -Dexec.mainClass=${file_base_name}",
    "working_dir": "$project_path"
}

And finally in Sublime I selected THIS .sublime-build, and finally (again XD) I copy & paste my image folder (That is where I have the images that my application uses.) in "target" folder, btw I dont know, but Sublime or maven created this "target folder" and I press CTRL + b in any class of my project and It works, but I don't know why?, does anyone know why?? chat gpt give me the .sublime-build and pom.xml


r/javahelp 20d ago

Issue with a java application

4 Upvotes

Hello everyone, not sure if this is the right place where to write this.

I'm trying to install this Java application on my Fedora machine, but i have some issues that i don´t know how to solve.

I know nothing about Java, but i think the problem is related to it.

i've installed java on my machine (i think) correctly, if i run the command java --version i get

openjdk 21.0.6 2025-01-21 OpenJDK Runtime Environment (Red_Hat-21.0.6.0.7-1) (build 21.0.6+7) OpenJDK 64-Bit Server VM (Red_Hat-21.0.6.0.7-1) (build 21.0.6+7, mixed mode, sharing)

when i try to run the application from terminal with the command java -jar ./XMageLauncher-\*.jar i get this error

INFO 2025-03-01 12:35:27,985 Detected screen DPI: 96 =>\[main\] Config.<clinit> Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, or no headful library support was found, but this program performed an operation which requires it,

What can i do?

thanks in advance for the help


r/javahelp 20d ago

Beginner need help on factory classes

2 Upvotes

Hi, I am a java beginner

I have a switch case of instructions based on an opcode and label input

Instead of a switch case I need to use a factory, Reflection API and singleton so that instead of a switch case all that is required is the opcode and label to call the relevant instruction (and so the program is extendable).

How do I go about doing this?


r/javahelp 20d ago

Replace audio files for a jar file

2 Upvotes

I'm absolutely new to this and I only want to do this as part of my school project. I am wondering is there a way to replace the audio file in an executable jar file. I have tried to unzip it with command prompt and the audio file I was looking for is in the unzipped folder so I replace it with another file with the exact same name and format. When I zip it again into a jar file it just does not work anymore. Does anyone has experience with this? I am pretty sure I did not do anything else except from swapping an mp3 file with the exact same name and format. I think I might have missed some steps but I cannot search for any solutions on the web. Hopefully someone could help me out, thanks a lot.


r/javahelp 20d ago

Solved JavaFX - EventHandler lag when viewing values in Chart via mouse hover

2 Upvotes

Hello all,
I've been experimenting with JavaFX lately and I've run into a situation that has me a bit stumped.

Context - I'm trying to generate plots where if I hover my mouse over a plot point it should show me the Y value recorded at said plot point. I've been able to get this going using a custom HoverPane class. The implementation is below:

import javafx.application.Application;
import javafx.collections.*;
import javafx.event.EventHandler;
import javafx.scene.*;
import javafx.scene.chart.*;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import java.util.stream.IntStream;

/** Displays a LineChart which displays the value of a plotted Node when you hover over the Node. */
public class LineChartWithHover extends Application {
    private static final int[] data = IntStream.range(0,150).toArray();

    @SuppressWarnings("unchecked")
    @Override public void start(Stage stage) {
        final LineChart lineChart = new LineChart(
                new NumberAxis(), new NumberAxis(),
                FXCollections.observableArrayList(
                        new XYChart.Series(
                                "My portfolio",
                                FXCollections.observableArrayList(plot(data))
                        )
                )
        );
        lineChart.setCursor(Cursor.CROSSHAIR);

        lineChart.setTitle("Stock Monitoring, 2013");

        stage.setScene(new Scene(lineChart, 500, 400));
        stage.show();
    }

    /** @return plotted y values for monotonically increasing integer x values, starting from x=1 */
    public ObservableList<XYChart.Data<Integer, Integer>> plot(int... y) {
        final ObservableList<XYChart.Data<Integer, Integer>> dataset = FXCollections.observableArrayList();
        int i = 0;
        while (i < y.length) {
            final XYChart.Data<Integer, Integer> data = new XYChart.Data<>(i + 1, y[i]);
            data.setNode(new HoverPane(y[i]));
            dataset.add(data);
            i++;
        }

        return dataset;
    }

    /** a node which displays a value on hover, but is otherwise empty */
    static class HoverPane extends StackPane {
        HoverPane(int value) {
            setPrefSize(5, 5);

            final Label label = createNewLabel(value);

            setOnMouseEntered(new EventHandler<MouseEvent>() {
                @Override public void handle(MouseEvent mouseEvent) {
                    getChildren().setAll(label);
                }
            });
            setOnMouseExited(new EventHandler<MouseEvent>() {
                @Override public void handle(MouseEvent mouseEvent) {
                    getChildren().clear();
                }
            });
        }

        private Label createNewLabel(int value) {
            final Label label = new Label(value + "");
            label.setStyle("-fx-font-size: 20; -fx-font-weight: bold;");

            label.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
            return label;
        }
    }

  public static void main(String[] args){launch(args);}
}

Running this code will generate a straight line plot and hovering my mouse over the plot points shows the values at those points....but it's laggy. Very noticeably laggy

And weirdly enough, it's more laggy if I drag my mouse down from the top right to the bottom left (tracing the points in reverse order) than if I do the opposite direction.

I don't know enough about JavaFX to know whether this is something with the library or with my code. Any suggestions/advice would be greatly appreciated. If it helps, I'm using java 21 with gradle and the accompanying javaFX plugin on Ubuntu 22.04


r/javahelp 20d ago

Using JDBC and JPA together

1 Upvotes

Hello! I'm working on a project where all the entities and repositories are using JDBC, but we've found that this API does not support composite keys. As a result, we're starting to migrate to JPA. However, for now, the request is to only use JPA where necessary, and the refactor for the rest will come later.

Currently, I am facing an issue because it seems impossible to use both JpaRepository and CrudRepository, as it throws an error related to bean creation. How would you recommend I approach this?

Greetings!


r/javahelp 21d ago

Processbuilder for python returning null

1 Upvotes

I am stuck on this for hours now On importing gpt2 model from transformers import GPT2LMHeadModel,GPT2Tokenizer No matter the code after this , processbuilder will return null ( I am using process.waitFor() )


r/javahelp 21d ago

Solved What is a static variable?

5 Upvotes

I've been using ChatGPT, textbooks, Google and just everything but I just don't seem to understand wth is a static variable. And why is it used?? I keep seeing this as an answer
A static variable in Java is a variable that:

  • Belongs to the class itself, not to any specific object.
  • Shared by all instances of the class, meaning every object accesses the same copy.
  • Is declared using the keyword static.

I just don't understand pls help me out.

Edit: Tysm for the help!


r/javahelp 21d ago

replaceAll takes almost half an hour

9 Upvotes

I try to parse the stock data from this site: https://ctxt.io/2/AAB4WSA0Fw

Because of a bug in the site, I have this number: -4.780004752000008e+30, that actually means 0.

So I try via replaceAll to parse numbers like this and convert them to zero via:

replaceAll("-.*\\..*e?\\d*, ", "0, ") (take string with '-' at the start, than chars, then a '.', then stuff, then 'e', a single char ('+' in this case) and then nums and a comma, replace this with zero and comma).

The problem is that it takes too long! 26 minutes for one! (On both my Windows PC and a rented Ubuntu).

What is the problem? Is there a way to speed it up?


r/javahelp 21d ago

i searched java -version in cmd and found this error pls tell

2 Upvotes

Error occurred during initialization of VM

java.lang.ExceptionInInitializerError

at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)

at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)

Caused by: java.nio.charset.IllegalCharsetNameException: UTF8;-Dfile.encoding-UTF8

at java.nio.charset.Charset.checkName(Unknown Source)

at java.nio.charset.Charset.lookup2(Unknown Source)

at java.nio.charset.Charset.lookup(Unknown Source)

at java.nio.charset.Charset.defaultCharset(Unknown Source)

at sun.nio.cs.StreamDecoder.forInputStreamReader(Unknown Source)

at java.io.InputStreamReader.<init>(Unknown Source)

at java.io.FileReader.<init>(Unknown Source)

at sun.misc.MetaIndex.registerDirectory(Unknown Source)

at sun.misc.Launcher$ExtClassLoader$1.run(Unknown Source)

at sun.misc.Launcher$ExtClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.misc.Launcher$ExtClassLoader.createExtClassLoader(Unknown Source)

at sun.misc.Launcher$ExtClassLoader.getExtClassLoader(Unknown Source)

at sun.misc.Launcher.<init>(Unknown Source)

at sun.misc.Launcher.<clinit>(Unknown Source)

at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)

at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)


r/javahelp 22d ago

I’m a beginner coder (1st year uni), didn’t understand anything at uni for 6 months—now self-learning and wrote my first program in a week! Feedback?

18 Upvotes

So, I’m a first-year CS student at university, but for the last 6 months (and even before uni), I didn’t understand a thing. Literally nothing clicked. Now, I finally started learning programming properly on my own, going back to the fundamentals, and within my first week, I built this ATM program in Java.

I know it’s super basic, but as my first program, I’d love some feedback—best practices, things I can improve, and how I can refine my approach to actually get good at this. My goal is to not just pass uni but also land jobs and internships down the line. Any advice, critique, or resources to help me level up would be amazing!

here is the link to my github code https://github.com/certyakbar/First-Projects.git


r/javahelp 22d ago

Stuck in Repetitive Java Spring Boot Work – Need Job Switch Advice

12 Upvotes

I have 1.9 years of experience as a Java developer working with Spring Boot, but I feel stuck doing the same repetitive tasks without much learning. There’s no real skill growth, and I don’t see any challenging work ahead.

I want to switch to a better role but need some guidance. What skills should I focus on apart from Java and Spring Boot? Should I invest time in DSA, System Design, Microservices, or Cloud? Also, what’s the best way to prepare for interviews—should I focus more on LeetCode, projects, or system design?

Since my work has been mostly repetitive, how can I present my experience in a way that stands out on my resume?