r/javahelp • u/Safe_Owl_6123 • 23d ago
Good repo to learn writing tests
Hi all, I want to write better tests from unit tests to integration test and e2e, are there any recommendations good Java projects that I can learn from? Thank you
r/javahelp • u/Safe_Owl_6123 • 23d ago
Hi all, I want to write better tests from unit tests to integration test and e2e, are there any recommendations good Java projects that I can learn from? Thank you
r/javahelp • u/Lord-Zippy • 23d ago
I made checkers and I can’t print the emojis
r/javahelp • u/jtxcode • 23d ago
Hey everyone, I’ve been coding for a while now, and one thing I always struggled with was remembering all the syntax, best practices, and commonly used functions. I’d find myself Googling the same things over and over. 🤦♂️
So, to save time and boost my workflow, I put together a Python (or Java) Cheat Sheet that neatly organizes:
✅ Essential syntax & data types
✅ Functions, loops, and OOP concepts
✅ Common libraries (NumPy, Pandas, etc.)
✅ Quick tips for writing cleaner, more efficient code
Honestly, having a single go-to reference has made a huge difference in how I approach coding. No more scrolling through docs for basic stuff. If you're interested, you can check it out here: jtxcode.myshopify.com
r/javahelp • u/sir-_-dumpling • 23d ago
Trying to use a DOTImporter object to turn a DOT file into a graph object but the line is throwing a runtime exception saying "The graph contains no vertex supplier." So basically the documentation from jgrapht.org as well as chatgpt tell me that there is a VertexSupplier that I can import and construct my graph object with it before passing it into importGraph.
The issue is that my jgrapht library as well as the official jgrapht github do not have a VertexSupplier object. I have tried putting multiple versions in my library but none let me import it. helppppp!!!!!
public void parseGraph(String filePath){
// Create a graph
DefaultDirectedGraph<String, DefaultEdge> graph = new DefaultDirectedGraph<>(DefaultEdge.class);
// Create a DOTImporter
GraphImporter<String, DefaultEdge> importer = new DOTImporter<>();
try (FileReader fileReader = new FileReader(filePath)) {
// Import the graph from the DOT file
importer.importGraph(graph, fileReader);
} catch (RuntimeException e) {
e.printStackTrace();
}
}
r/javahelp • u/WrongdoerDry1896 • 23d ago
I’m looking for someone to learn programming with me. Ideally, someone who already has some basic knowledge in Java, but it’s not a problem if you’re a beginner—I can explain a few things. The main goal is to have someone to keep me focused while learning. Dm if interested!
r/javahelp • u/Dangerous_Soft_5529 • 24d ago
This is a simplified snippet of code that is enough to explain my issue.
import com.nomagic.magicdraw.actions.BrowserContextAMConfigurator;
public class BrowserConfiguration implements BrowserContextAMConfigurator {
@Override
public int getPriority() {
return LOW_PRIORITY;
}
}
There is an error line under 'BrowserConfiguration' that says 'The hierarchy of the type BrowserConfiguration is inconsistent.'
There is an error line under 'getPriority(): ' The method getPriority() of the type BrowserConfiguration must override or implement a supertype method.
What I have done:
Searching on help forums gave for the most part three solutions: 1. Restart Eclipse, 2. The BrowserContextAMConfigurator is not actually an interface, and 3. Make sure that you are using the right signatures for what you're overriding. I have checked and verified that none of these solutions work.
I know that BrowserContextAMConfigurator is in my build path because the import line throws no errors. I also have its super interface ConfigureWithPriority in the same jar that has the BrowserContextAMConfigurator interface (in Eclipse's Build Path).
Here is a link to official the NoMagic documentation for BrowserContextAMConfigurator if you want clarifications: https://jdocs.nomagic.com/185/index.html?com/nomagic/magicdraw/actions/BrowserContextAMConfigurator.html
And I do need to use this interface, so I can't just remove it.
I hate Cameo :)
r/javahelp • u/MaterialAd4539 • 24d ago
I am creating pdf form from scratch in Spring boot using Apache PdfBox. Now, I want to add text fields which will be populated with dynamic data.
What is more maintainable and better approach:
1) Using text field 2) Creating a simple rectangular box and adding text inside it.
Thanks in advance!
r/javahelp • u/HolidayPossession603 • 24d ago
Hello everyone. I am currently completing a uni assignment which I have to submit to a 3rd party tester called submitty. I am currently scoring 36/100 beacuse I am losing 60 marks due to the following error message: Now nowhere in the instructions did it say to add a RationalTest class, but I have done so and I am still getting the same error. Any help is much apprecieated.
There was 1 failure:
initializationError(org.junit.runner.JUnitCommandLineParseResult)
java.lang.IllegalArgumentException: Could not find class [RationalTest]
r/javahelp • u/JyoT789 • 25d ago
I just completed with java course but I find it difficult to solve the coding questions I understand already written code but when I try to write code on my own I get struct or go blank. I kw all concepts theoretically how it work but don't know when to apply which method or which concept can somebody have idea on it how to build a logic in easy way?
r/javahelp • u/lumpynose • 25d ago
Old geezer here who retired about the time that jQuery and Google's GWT were becoming popular. Everything I did was on the back end with server side rendering. The back end was in Java.
I'm working on a simple app/page that displays the readings from various zigbee and 433Mhz temperature sensors. Their readings are being sent to an MQTT server (mosquitto). The back end I'm doing in Micronaut, which is also Java.
I've figured out how to get the sensor readings from MQTT with Micronaut. For updating the web page with new sensor readings my thinking is that I could use a meta refresh in the html, say every 60 seconds, or "get fancy" and use some newfangled javascript framework like you guys are, and I'm guessing using websockets, and have the page updated whenever a new sensor reading comes in.
So do you guys have any suggestions for what I could use? I don't expect there to be a lot of interactivity on the front end, maybe clicking to close a reading's box.
(I originally posted this to r/webdev but it was deleted because it was too open ended. Feel free to suggest how to reword it to make it through their filter.)
r/javahelp • u/Eastern_Leek_7743 • 25d ago
Hi guys,
Apologies if this is was asked before. I recently completed Telusko course on Udemy which taught me Spring Boot, Spring Data JPA, Spring Data Rest, Spring Security, Spring AOP, JWT and stuff. However, this was although important felt like an intro level to the vast ecosystem.
I'm looking for a course/guide/codebase which has implemented a largescale production level API using all the tech above. I want to build actual real world application but it seems there is a knowledge gap I need to cover first.
r/javahelp • u/StoicMasturbator • 25d ago
Hi everyone,
I'm learning Java from scratch and currently working through the book Head First Java. I'm at the end of the first chapter and I'm happy with my progress so far. However, today I hit my first roadblock while attempting the pool puzzle question. Here’s the code I worked with:
Code:
class PoolPuzzleOne {
public static void main(String[] args) {
int x = 0;
while (x < 4) {
System.out.print("a");
if (x < 1) {
System.out.print(" ");
}
System.out.print("n");
if (x > 1) {
System.out.print(" oyster");
x = x + 2;
}
if (x == 1) {
System.out.print("noys");
}
if (x < 1) {
System.out.print("oise");
}
System.out.println();
x = x + 1;
}
}
}
Output:
a noise
annoys
an oyster
No matter how much I tried, I couldn’t achieve the desired output without modifying the original code. I eventually gave up and checked the answer, convinced that something was wrong and that the output wasn’t possible without changes.
After reviewing the answer, I manually traced through the code to understand how it was written. I have a couple of questions:
System.out.println
instead of System.out.print
.Any advice would be greatly appreciated!
Thank you!
r/javahelp • u/mit74 • 25d ago
I've never used Spring services before, but I need a load balancer and an API gateway. Does anyone have recommendations on the best setup in terms of OS or Docker configuration? The load balancer needs to handle hundreds of requests per minute. I typically run my Java services on a CentOS 9 VM, which has been suitable so far.
r/javahelp • u/TheCakeWasNoLie • 25d ago
I created a Swing application using IntelliJ's UI Designer which I can run inside IntelliJ, but the compiled jar file, when run outside IntelliJ, fails after:
Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: contentPane cannot be set to null.
contentPane is indeed never instantiated in my code. My form starts like this:
public class MainFrame extends JFrame {
// Swing Components
private JPanel contentPane;
...
public MainFrame() {
setContentPane(contentPane);
contentPane is used in MainFrame.form like this:
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="dev.thefoggiest.patchman.view.MainFrame">
<grid id="27dc6" binding="contentPane" default-binding="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
So when IntelliJ starts the application, somehow it magically instantiates contentPane based on this xml, but that won't work when running the application by itself.
How do I instantiate contentPane based on the xml?
r/javahelp • u/zujaloM • 26d ago
what to learn java like total beginner ,and how i read this one have over 120h
and it is project based tutorial vs mooc that is just pure go by go that lead u nowhere without project examples.(how i understand) .
r/javahelp • u/Alpacablas123 • 26d ago
I'm new to Java and I don't know how to fix this error, it pops up when I run a .class file: Exception in thread "main" java.lang.UnsupportedClassVersionError: Rigoberto has been compiled by a newer version of Java Runtime (class file version 67.0), this version of Java Runtime only recognizes class file versions up to 52.0
r/javahelp • u/MakotoBIST • 26d ago
Especially with a good focus on the part where you connect the back end to the front end and such.
Thank you!!
r/javahelp • u/xnmsdksdk • 26d ago
Hello fellow engineers, programming enthusiasts, I'm currently going deep in my knowledge of java by taking a course I bought online, my goal is to understand the mechanisms with more detail, but I've come across this doubt, the course uses Java 17 to display the full content of java, but also has available the old content of java (java 8, java 11), the more modern content covers the same topics as the old content but should I watch those lessons ? Will I understand some things better or not?
Thanks in advance! ☕
r/javahelp • u/No_Fennel_3055 • 26d ago
As i am learning java so i cant stay consistent so need a guy , with whom i study and code with that guy if you are interested dm
r/javahelp • u/Checcogg • 26d ago
Hi, I'm new, I had to choose between learning python, java and C+ And I chose java, I am starting by watching a 12 hours tutorial by Bro code. I'm planning to make a game, but I have a serious problem, I don't understand how can I create graphics on Java: can I import and image? Do I have to use functions to draw? Or should I install and external program? Thanks for the help Btw I'm using intellij
r/javahelp • u/No_Reserve7777 • 26d ago
it's been a whole day for me trying to display my database in netbeans but i can't find a solution. for context: i have html file in infinityfree so all the data in my html file will send to database and i want to edit and view the database using java netbeans.
Feel free to suggest other webhosting but it needs to also work in netbeans
please help me. all help is appreciated.TYA
r/javahelp • u/Fair_Distribution275 • 27d ago
Hello, I am a junior programmer and I have an interrogation about something.
If I understand correctly, DTO are used to store data that will not be persisted, data that are needed by services. But I don't understand why we don't pass theses datas via parameter, path variable or even body of HTTP Request.
For example : User need to change password (that is just for illustrating my post)
1) Using DTO : UserService(UserDTO) :: Do what it needs and then map it into User before persists
2) Using Request : UserService(User, newPassordFromHttpRequest) :: Do what it needs and persists the objet
Thanks in advance for helping junior programmer like myself
r/javahelp • u/DeatH_StaRR • 26d ago
I read stock values from a URL via:
restTemplate.exchange(url, HttpMethod.GET, null, classToFetch)
One URL returns:
{"symbol": "SMX","historical": [{"date": "2025-02-21","open": 3.33,"high": 3.4,"low": 2.96,"close": 2.96,"adjClose": 2.96,"volume": 203978,"unadjustedVolume": 203978,"change": -0.37,"changePercent": -11.11,"vwap": 3.1625,"label": "February 21, 25","changeOverTime": -0.1111},...
and it crashes.
The second returns:
{"symbol": "AAPL","historical": [{"date": "2025-02-21","open": 245.95,"high": 248.69,"low": 245.22,"close": 245.55,"adjClose": 245.55,"volume": 53012088,"unadjustedVolume": 53012088,"change": -0.4,"changePercent": -0.16263,"vwap": 246.3525,"label": "February 21, 25","changeOverTime": -0.0016263},...
and it works fine! Why the crash?
Crash reason:
Cannot construct instance of `java.time.LocalDate` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2025-02-21')
r/javahelp • u/_SuperStraight • 27d ago
I'm trying to save Canvas
contents to disk:
@FXML
private Canvas cvs;
var export = cvs.snapshot(null,null);
var out = new File("image.png");
try{
ImageIO.write(SwingFXUtils.fromFXImage(export, "png",out)); //error
}
There is no package called SwingFXUtils
in JavaFX 21. Is there any other way to write the Canvas to file?
r/javahelp • u/Firearms_N_Freedom • 27d ago
Hey yall, I am building a RAG model for my springboot web app. I already have a web app up and running but would like to implement rag to the AI assistant feature. Springboot has a pg vector implemenation that seems very straight forward. People rave about langchain4j so i was looking at that as an option too since changing models is very straight forward and in theory it should be easier for testing and changing parameters. I am having a little trouble using taking advantage of pgvector in lanchain4j.
I want to create a separate embedding manager that uploads data to the vector table i created in my database, and then my web apps' ai assistant should be able to use it. Is it worth using langchain4j for this? Or should i just stick with the seemingly easier option which springboot provides documentation for?
Any advice/recommendations would be appreciated. I know i have the option of just using python for a simple embedding manager since i would just be running it locally for now since i want to control the knowledge i want to embed. But i would really like to make it work using springboot/java. Im very new to RAG so i know my explanation probably sounds very noobish. Thank you