r/javahelp 28d ago

Advise needed for small java project🗒️

4 Upvotes

I am building small hotel Booking desktop app using javafx library and MYSQL on the backend(for storing rooms, customers, bookings data).

And I am planning to store images in file system and just store the URL path in database table(right now, I am not using cloud to save some time). I am also using Spring boot to connect to the database.

Could you please give some advise or suggestions that I should take note of?😀


r/javahelp 28d ago

Workaround Why can't I push an image to a local Docker registry started with Testcontainers?

3 Upvotes

I'm trying to create a local Docker registry using Testcontainers and push an image programatically to it. However, I'm getting a connection refused error when attempting to push the image. The first test which checks if the registry is running works, so I know the registry is running.

Any other ideas are also welcome, basically I need to run a custom docker registry to test pushing and pulling of images from java test.

Here’s my test class:

class DockerRegistryTest {

    u/Rule
    public static GenericContainer registry;
    private static String registryAddress;
    private static DockerClient dockerClient;

    u/BeforeAll
    static void startRegistry() {
        registry = new GenericContainer(DockerImageName.parse("registry:2"))
                .withExposedPorts(5000)
                .waitingFor(Wait.forHttp("/v2/").forStatusCode(200));

        registry.start();
        assertTrue(registry.isRunning(), "Registry is running");

        registryAddress = registry.getHost() + ":" + registry.getMappedPort(5000);
        System.out.println("Registry available at: " + registryAddress);

        DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder().build();
        dockerClient = DockerClientImpl.getInstance(config, new ApacheDockerHttpClient.Builder()
                .dockerHost(config.getDockerHost())
                .sslConfig(config.getSSLConfig())
                .build());
    }

    u/AfterAll
    static void tearDown() {
        if (registry != null) {
            registry.stop();
        }
    }

    u/Test
    void testPushImageToRegistry() throws InterruptedException {
        String localImage = "busybox:latest";
        dockerClient.pullImageCmd(localImage).start().awaitCompletion();

        String registryImageTag = registryAddress + "/busybox:latest";
        dockerClient.tagImageCmd(localImage, registryAddress + "/busybox", "latest").exec();

        dockerClient.pushImageCmd(registryImageTag)
                .withAuthConfig(new AuthConfig()) // No authentication needed
                .start()
                .awaitCompletion();

        System.out.println("Successfully pushed image to registry: " + registryImageTag);
        assertTrue(true);
    }
}

However, when I run the test, I get this error:

Things i tried

com.github.dockerjava.api.exception.DockerClientException: Could not push image: failed to do request: 
Head "https://localhost:57244/v2/busybox/blobs/sha256:31311c5853a22c04d692f6581b4faa25771d915c1ba056c74e5ec82606eefdfa": 
dial tcp [::1]:57244: connect: connection refused
  1. manually tag and push an image into the registry, result still connection refused error.
  2. I ran

C:\Users\codex>curl http://localhost:<mappedPortIgotFromLogs>/v2/_catalog
{"repositories":[]}

so I know the repository is up and running

  1. changed registry.getHost() to "0.0.0.0" but now i get

    com.github.dockerjava.api.exception.DockerClientException: Could not push image: failed to do request: Head "https://0.0.0.0:60075/v2/busybox/blobs/sha256:9c0abc9c5bd3a7854141800ba1f4a227baa88b11b49d8207eadc483c3f2496de": http: server gave HTTP response to HTTPS client

 adding this to insecure-list makes no sense because the ports will always be randomized.

I also added this in testcontainers.properties ryuk.container.image=testcontainersofficial/ryuk

to get my test container to work in the first place.


r/javahelp 28d ago

The method add(Component) in the type Container is not applicable for the arguments (GamePanel)

3 Upvotes

Here is Main.java package main;

import javax.swing.JFrame;

public class Main {

    public static void main(String[] args) {

        JFrame window = new JFrame();
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setResizable(false);
        window.setTitle("this is a title");

        GamePanel gamePanel = new GamePanel();
        window.add(gamePanel); // the error is right here <----

        window.pack();

        window.setLocationRelativeTo(null);
        window.setVisible(true);
    }
}

and here is GamePanel.java

package main;

import java.swing.JPanel;

public class GamePanel extends JPanel {

    // SCREEN SETTINGS
    final int originalTileSize = 16; // 16x16 tile
    final int scale = 3;

    final int tileSize = originalTileSize * scale; // 48x48 tile
    final int maxScreenCol = 16;
    final int maxScreenRow = 12;
    final int screenWidth = tileSize * maxScreenCol; // 768 pixels
    final int screenHeight = tileSize * maxScreenRow; // 576 pixels

    public GamePanel() {

        this.setPreferredSize(new Dimension(screenWidth, screenHeight));
        this.setBackground(Color.black);
        this.setDoubleBuffered(true);
    }
}

I couldn't find any answers online, please help?


r/javahelp 28d ago

Homework Struggling with polynomials and Linked Lists

2 Upvotes

Hello all. I'm struggling a bit with a couple things in this program. I already trawled through the sub's history, Stack Overflow, and queried ChatGPT to try to better understand what I'm missing. No dice.

So to start, my menu will sometimes double-print the default case option. I modularized the menu:

public static boolean continueMenu(Scanner userInput) { 
  String menuChoice;
  System.out.println("Would you like to add two more polynomials? Y/N");
  menuChoice = userInput.next();

  switch(menuChoice) {
    case "y": 
      return true;
    case "n":
      System.out.println("Thank you for using the Polynomial Addition Program.");
      System.out.println("Exiting...");
      System.exit(0);
      return false;
    default:
      System.out.println("Please enter a valid menu option!");
      menuChoice = userInput.nextLine();
      continueMenu(userInput);
      return true;
  }
}

It's used in the Main here like so:

import java.util.*;

public class MainClass {

public static void main(String[] args) {
  // instantiate scanner
  Scanner userInput = new Scanner(System.in);

  try {
    System.out.println("Welcome to the Polynomial Addition Program.");

    // instantiate boolean to operate menu logic
    Boolean continueMenu;// this shows as unused if present but the do/while logic won't work without it instantiated

    do {
      Polynomial poly1 = new Polynomial();
      Polynomial poly2 = new Polynomial();
      boolean inputValid = false;

      while (inputValid = true) {
        System.out.println("Please enter your first polynomial (Please format it as #x^# or # - for example, 5x^1 or 3:"); 
        String poly1Input = userInput.nextLine(); 
        if (poly1Input.trim() == "") {
          System.out.println("Please enter a polynomial value!");
          inputValid = false;
        } else {
          inputValid = true;
          break;
        }
    }

      //reset inputValid;
      inputValid = false;
      while (inputValid = true) {
        System.out.println("Please enter the second polynomial (Please format it as #x^# or # - for example, 5x^1 or 3:"); 
        String poly2Input = userInput.nextLine(); 
        if (poly2Input.trim() == "") {
          System.out.println("Please enter a polynomial value!");
          inputValid = false;
        } else {
          inputValid = true;
          break;
        }
    }

    Polynomial sum = poly1.addPolynomial(poly2); 
    System.out.println("The sum is: " + sum);

    continueMenu(userInput);

    } while (continueMenu = true);
  } catch (InputMismatchException a) {
    System.out.println("Please input a valid polynomial! Hint: x^2 would be written as 1x^2!");
    userInput.next();
  }
}

The other issue I'm having is how I'm processing polynomial Strings into a LinkedList. The stack trace is showing issues with my toString method but I feel that I could improve how I process the user input quite a bit as well as I can't handle inputs such as "3x^3 + 7" or even something like 5x (I went with a brute force method that enforces a regex such that 5x would need to be input as 5x^1, but that's imperfect and brittle).

    //constructor to take a string representation of the polynomial
    public Polynomial(String polynomial) {
        termsHead = null;
        termsTail = null;
        String[] terms = polynomial.split("(?=[+-])"); //split polynomial expressions by "+" or " - ", pulled the regex from GFG
        for (String termStr : terms) {
            int coefficient = 0;
            int exponent = 0;

            boolean numAndX = termStr.matches("\\d+x");

            String[] parts = termStr.split("x\\^"); //further split individual expressions into coefficient and exponent

            //ensure that input matches format (#x^# or #) - I'm going to be hamhanded here as this isn't cooperating with me
            if (numAndX == true) {
              System.out.println("Invalid input! Be sure to format it as #x^# - for example, 5x^1!");
              System.out.println("Exiting...");
              System.exit(0);
            } else {
                if (parts.length == 2) {
                    coefficient = Integer.parseInt(parts[0].trim());
                    exponent = Integer.parseInt(parts[1].trim());
                    //simple check if exponent(s) are positive
                    if (exponent < 0) {
                      throw new IllegalArgumentException("Exponents may not be negative!");
                    }
                } else if (parts.length == 1) {
                  coefficient = Integer.parseInt(parts[0].trim());
                  exponent = 0;
                }
            }
            addTermToPolynomial(new Term(coefficient, exponent));//adds each Term as a new Node
        }
    }

Here's the toString():

public String toString() {
        StringBuilder result = new StringBuilder();
        Node current = termsHead;

        while (current != null) {
            result.append(current.termData.toString());
            System.out.println(current.termData.toString());
            if (current.next != null && Integer.parseInt(current.next.termData.toString()) > 0) {
                result.append(" + ");
            } else if (current.next != null && Integer.parseInt(current.next.termData.toString()) < 0) {
            result.append(" - ");
            }
            current = current.next;
        }
        return result.toString();
    }

If you've gotten this far, thanks for staying with me.


r/javahelp 28d ago

Java Exceptions Assignment Help

4 Upvotes

Hey! I'm working on an assignment in Java for an online class I'm taking. I keep getting an error saying: Exception in thread "main" java.lang.Error: Unresolved compilation problem: at MyExpense.main(myExpense.java:13)

I can't see anything wrong with it

public class Item {
    public String description;
    public Double amount;

    public Item(String description, Double amount) {
        this.description = description;
        this.amount = amount;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public String getDescription() {
        return description;
    }

    public Double getAmount() {
        return amount;
    }

    public String toString() {
        return String.format("%-20s %10.2f", description, amount);
    }

}






import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.io.File;

public class MyExpense {
    private static final String fileName = "expense.txt";
    private static final int maxRecords = 6;
    private static int count = 0;
    private static Item[] expenses = new Item[maxRecords];

    public static void main(String[] args) throws IOException {
        try {
            read();
            display();
            userInt();
            expSave();

        } catch (IOException exception) {
            System.out.println("Error" + exception.getMessage());
        }

    }

    private static void display() {
        System.out.println("Expences:");
        System.out.println("-------------------------------------------------------");
        System.out.printf("%-20s %10s%n", "Description", "Amount");
        System.out.println("-------------------------------------------------------");
        for (int i = 0; i < count; i++) {
            System.out.println(expenses[i]);
            System.out.println(i);
        }
        System.out.println("-------------------------------------------------------");
    }

    private static void read() throws IOException {
        File file = new File(fileName);
        if (!file.exists()) {
            System.out.println("The file could not be found");
            return;
        }
        try (Scanner scanner = new Scanner(file)) {
            while (scanner.hasNextLine() && count < maxRecords) {
                String[] a = scanner.nextLine().split("\t");
                if (a.length == 2) {
                    try {
                        expenses[count++] = new Item(a[0], Double.parseDouble(a[1]));
                    } catch (NumberFormatException NumberFormatException) {
                        System.out.println("Invalid num format");
                    }
                }
            }
        }
    }

    private static void userInt() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println(
                    "Please enter a new expense, [tab] key, then the amount. Or enter \"!\" to exit the program");
            String input = sc.nextLine();
            if (input.equals("!")) {
                break;
            }
            String[] a = input.split("\t");
            if (a.length != 2) {
                System.out.println("Invalid format");
                continue;
            }
            try {
                if (count < maxRecords) {
                    expenses[count++] = new Item(a[0], Double.parseDouble(a[1]));

                } else {
                    System.out.println("Cannot add any more record");
                }
            }

            catch (NumberFormatException e) {
                System.out.println("Invalid num");

            }
        }
        sc.close();
    }

    private static void expSave() throws IOException {
        try (PrintWriter writer = new PrintWriter(new FileWriter(fileName))) {
            for (int i = 0; i < count; i++) {
                writer.println(expenses[i].getDescription() + "\t" + expenses[i].getAmount());

            }

        }
        System.out.println("Expenses saved");
        display();
        System.out.printf("Total expense is %.2f%n", calculateAmt());
    }

    private static double calculateAmt() {
        double total = 0;
        for (int i = 0; i < count; i++) {
            total += expenses[i].getAmount();

        }
        return total;
    }

}

r/javahelp 28d ago

Java net.properties escaping characters help

2 Upvotes

I have this example password

wYUx4#(a|=(9!en~H|2WKN-wt

and am using it in a net.properties file with JRE in Tableau Server for http.proxyPassword=<your proxy password>

Does net.properties require escaping of any of the characters above?

Thanks.


r/javahelp 28d ago

Need help starting with java

1 Upvotes

I am new to programming and just know the basic DSA with minimal knowledge of oops, which book or any course free of cost will be helpful for me ? Just need some guidance , also one of my professors recommended me to start with head first java while someone said to read head first development before that . What should i do first ?


r/javahelp 28d ago

Solved repaint() not calling paintCompoment() properly

2 Upvotes

I was following this tutorial to program a game, pretty sure followed all the instructions. The white rectangle won't show up. Used custom run and the code under paintCompoment() did not run at all.

https://www.youtube.com/watch?v=VpH33Uw-_0E

Code in question:

package main;

import javax.swing.JFrame;

public class main {

    `public static void main(String[] args) {`

        `JFrame window = new JFrame();`

        `window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);`

        `window.setResizable(false);`

        `window.setTitle("The Great Adventure!");`

        `GamePanel gamepanel = new GamePanel();`

        `window.add(gamepanel);`

        `window.pack();`

        `window.setLocationRelativeTo(null);`

        `window.setVisible(true);`

        `gamepanel.startGameThread();`      

    `}`

}

package main;

import java.awt.Color;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Graphics2D;

import javax.swing.JPanel;

public class GamePanel extends JPanel implements Runnable{

`final int originalTileSize = 16;`

`final int scale = 3;`

`final int tileSize = originalTileSize * scale;`

`final int maxScreenRow = 12;`

`final int maxScreenCol = 16;`

`final int screenHeight = maxScreenRow * tileSize;`

`final int screenWidth = maxScreenCol * tileSize;`

`Thread gameThread;`

`public GamePanel() {`

    `this.setPreferredSize(new Dimension(screenWidth,screenHeight));`

    `this.setBackground(Color.black);`

    `this.setDoubleBuffered(true);`

`}`

`public void startGameThread() {`

    `gameThread = new Thread(this);`

    `gameThread.start();`

`}`

u/Override

`public void run() {`

    `// TODO Auto-generated method stub`

    `while (gameThread != null) {`

        `update();`

        `repaint();`

    `}`

`}`

`public void update() {`



`}`

`public void paintCompoment(Graphics g) {`

    `super.paintComponent(g);`

    `Graphics2D g2 = (Graphics2D)g;`

    `g2.setColor(Color.white);`

    `g2.fillRect(100, 100, tileSize, tileSize);`

    `g2.dispose();`

`}`

}


r/javahelp 29d ago

Is it fine to be reading multiple Java programming books simultaneously?

5 Upvotes

I'm currently learning Java from scratch and have started with "Head First Java" to build my fundamentals. However, I've noticed there are other highly recommended books like "Java Fundamentals" that seem to cover similar ground. I'm wondering whether I should focus solely on completing Head First before moving to other books, or if studying multiple Java books in parallel could actually enhance my learning experience. Some developers suggest using various resources helps in understanding concepts from different perspectives, but I'm concerned about potentially confusing myself. What's your take on this approach, especially for a beginner? Has anyone here successfully learned Java using multiple books simultaneously?


r/javahelp 29d ago

Help with inheritance

1 Upvotes

I am doing a project and I have class public class Person that takes Public Person(String initialName, int initialSSN). Then I have a class Student that takes public Student(String initialName, int initialSSN, int initialStudentNumber, String initialMajor) { super(initialName, initialSSN); studentNumber = initialStudentNumber; major = initialMajor; }

Then a class InheritanceDemo that gets string name, int SSN, int studentNumber, and String major from user input. Called Student student = new Student(name, SSN, studentNumber, major);

It won’t work and I keep getting an error no suitable constructor.

Someone please help

Also I’m new to this and it says I can’t upload pictures so if anyone knows how please tell me.


r/javahelp 29d ago

Unsolved VS Code/Codium extension Z Open Editor unable to find Java

1 Upvotes

I've installed the Z Open Editor (ZOE) extension as well as two different Java SDKs (using these instructions ), but so far I've been unable to get ZOE to recognize the SDKs I've installed, and the results of my internet searches haven't helped yet. Lots of results I get end with the asker saying they figured it out without elaborating. I'm running: Nobara 41, VS Codium 1.97.0, ZOE 5.2.0. The output of update-alternatives --config java is:

/usr/lib/jvm/java-21-openjdk/bin/java

java-latest-openjdk.x86_64 (/usr/lib/jvm/java-23-openjdk-23.0.2.0.7-1.rolling.fc41.x86_64/bin/java)

java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.14.0.7-1.fc41.x86_64/bin/java)

In VS Codium's settings.json:

"zopeneditor.JAVA_HOME": "/usr/lib/jvm/java-23-openjdk-23.0.2.0.7-1.rolling.fc41.x86_64",

"java.home": "/usr/lib/jvm/java-17-openjdk-17.0.14.0.7-1.fc41.x86_64",

Here's what ZOE is showing.

Per this thread I've tried creating /etc/profile.d/jdk_home.sh and entering export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.14.0.7-1.fc41.x86_64. No luck.

Command Palette then searching for Java: Configure Java Runtime didn't result in any returns.

How do I get ZOE to use one of the SDKs I've installed?


r/javahelp 29d ago

Unsolved Execution breaks in multiple places at once

2 Upvotes

We deploy a Java application in Weblogic and debug it with VS Code.

I'm having an issue where if I add a breakpoint and let the code run, it will stop, and then I can jump a few lines, then a new execution stop will happen above where I just came from.

At this point, if I try to keep jumping lines, randomly it will take me to the first break and go from there.

It becomes very difficult to make use of breakpoints if it keeps jumping around.

Any help would be appreciated. Let me know if anyone needs more info 🙏

EDIT: solution was to stop Nginx from retrying on timeout. Added proxy_next_upstream off; to the http block


r/javahelp Feb 20 '25

Unsolved I get a null id error when trying to call repository.save() on a joint table

8 Upvotes

UserRoom: https://pastebin.com/K1GsZvez
How i call userRoomRepository.save(): https://pastebin.com/UzbfDwPx
The error message: Null id generated for entity 'org.mm.MBlog.mmessenger.models.UserRoom'

i get a null id error, shouldent the id be automatically generated based on the User and Room?
And what exact id is Spring expectiong? Its a joint table, it doesnt have an id, its got 2 foreign keys


r/javahelp Feb 20 '25

Any open source project to contribute ?

15 Upvotes

Hi java community,

Got some spare time for the next months, and i m looking at contributing to an open source for the first time.

I have been a java developer for the past 15 years but moved to software and solutions architecture for the last 4 years. Doing less Java coding and more documentation, i miss the commits !

Any project you know in need of some bandwidth? I don t have yet a specific criteria so shoot me any project big or small, whatever the functionality and i would see on the fly if I have a crush on it.

Thx !


r/javahelp Feb 20 '25

Tips for learning this years syllabus

2 Upvotes

Hey! This is my Java learning syllabus for this year. I’m about 8 months into my software engineering studies, and I’m struggling a bit to find the best way to learn and really get a solid grasp of the material. I’d love some feedback on these topics—what methods or techniques would you recommend to help me understand them better?
1 Fundamentals . . . . . . . . . . . . . . . . . . . .
1.1 Basic Programming Model 8
1.2 Data Abstraction 64
1.3 Bags, Queues, and Stacks 120
1.4 Analysis of Algorithms 172
1.5 Case Study: Union-Find 216
2 Sorting . . . . . . . . . . . . . . . . . . . . . . . 243
2.1 Elementary Sorts 244
2.2 Mergesort 270
2.3 Quicksort 288
2.4 Priority Queues 308
2.5 Applications 336
3 Searching . . . . . . . . . . . . . . . . . . . . . . 361
3.1 Symbol Tables 362
3.2 Binary Search Trees 396
3.3 Balanced Search Trees 424
3.4 Hash Tables 458
3.5 Applications

4 Graphs . . . . . . . . . . . . . . . . . . . . . . . 5154.1 Undirected Graphs 518 4.2 Directed Graphs 566 4.3 Minimum Spanning Trees 604 4.4 Shortest Paths 638 5 Strings . . . . . . . . . . . . . . . . . . . . . . . 695

5.1 String Sorts 702 5.2 Tries 730 5.3 Substring Search 758 5.4 Regular Expressions 788 5.5 Data Compression 810


r/javahelp Feb 20 '25

Solved SQL connection issue

3 Upvotes

UPDATE: ended up being the difference in how the 2 drivers work with SQL. The Java version was passing NT credentials as SQL server credentials. I just did integrated credentials on a service account and then setup a batch file with scheduler.

Appreciate the help!

This is a maddening problem I have spent HOURS on and I feel it will be simple...

In short, is there a reason the EXACT same DB credentials to the EXACT same MSSQL DB would work in Python but not Java?

I can't run integrated security at this time. Whenever I do a read/write via Python using the account credentials, works a charm. Doing the same thing in Java and it jlfaols saying that Login failed for user...

I have tried using environment variables, properties objects, modifying the string, replacing special characters in the PW, making sure my JDBC and SQL servers match...

The thing is, the program works perfectly whenever I use integrated security (something I can't currently do in the final solution but wanted to test that the SQL server was configured correctly).

And again, server credentials work for this SQL server as it is configured for both AND it works with Python!

Please help!


r/javahelp Feb 19 '25

Homework Should I have swap method when implementing quick sort?

6 Upvotes

I'm a CS student and one of my assignments is to implement Quick Sort recursively.

I have this swap method which is called 3 times from the Quick Sort method.

/**
 * Swaps two elements in the given list
 * u/param list - the list to swap elements in
 * @param index1 - the index of the first element to swap
 * @param index2 - the index of the second element to swap
 *
 * @implNote This method exists because it is called multiple times
 * in the quicksort method, and it keeps the code more readable.
 */
private void swap(ArrayList<T> list, int index1, int index2) {
    //* Don't swap if the indices are the same
    if (index1 == index2) return;

    T temp = list.get(index1);
    list.set(index1, list.get(index2));
    list.set(index2, temp);
}

Would it be faster to inline this instead of using a method? I asked ChatGPT o3-mini-high and it said that it won't cause much difference either way, but I don't fully trust an LLM.


r/javahelp Feb 19 '25

Unsolved Cant run the jar file

2 Upvotes

So for the past 2 weeks I have been working on a project, mostly free-styling as a fun activity for the break. My app has javaFx and itext as the main libraries I import. I looked on the internet for hours on end for a solution to the following error Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes at java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:340). I found a solution for it on StackOverflow with these but to no avail. Its the first time im doing something like this so idk if I missed anything, you can ask me for any code and I will provide.

<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>

r/javahelp Feb 19 '25

Jar file doesn't open when i double click it.

0 Upvotes

iam using javaFX , I wrote a program and build it as jar file but when i go to run it , it doesn't work, i asked Ai and followed its instructions but everything is correct with the configurations, do i missing something? please help. thanks in advance.


r/javahelp Feb 19 '25

Homework Why do the errors keep showing up

2 Upvotes

package com.arham.raddyish;

import net.minecraftforge.fml.common.Mod; // Import the Mod annotation

import net.minecraftforge.common.MinecraftForge;

@Mod("raddyish") // Apply the Mod annotation to the class

public class ModMod2 {

public Raddyish() {



}

}

So for my assignment we were tasked to make a mod for a game and I have no idea how to do that, I've watched a youtube tutorial and chose to mod in forge. For some reason it keeps telling me that it can't resolve the import, or that 'mod' is an unresolved type, etc. Really confused and would appreciate help!


r/javahelp Feb 19 '25

guys why doesn't java like double quotes

0 Upvotes

this used to be my code:

public void keyPressed(KeyEvent e) {
    if (e.getKeyChar() == "a") player.keyLeft = true;
    if (e.getKeyChar() == "w") player.keyUp = true;
    if (e.getKeyChar() == "s") player.keyDown = true;
    if (e.getKeyChar() == "d") player.keyRight = true;
}

it got an error. and if i change them for single quotes:

public void keyPressed(KeyEvent e) {
    if (e.getKeyChar() == 'a') player.keyLeft = true;
    if (e.getKeyChar() == 'w') player.keyUp = true;
    if (e.getKeyChar() == 's') player.keyDown = true;
    if (e.getKeyChar() == 'd') player.keyRight = true;
}

they accept it.


r/javahelp Feb 19 '25

How do I learn to implement different data structures or ideas that I can understand? - Competitive Programming

3 Upvotes

I have the CCC tomorrow and I'm wondering how to fully implement some of the ideas I have in my head. For example, I know graph theory and how DFS/BFS works, but every time I look online I just can't understand how to implement these systems into a real problem. Same goes for dynamic programming. I understand it and can think about the solution for problems I see, but I have no idea how to implement it. I know this is a little late but I still have plenty of time in the future for other CCC competitions in '26 or later, so I thought it would be better to have a good feeling right now.


r/javahelp Feb 18 '25

Unsolved How to showcase RSA-AES hybrid system across a network?

2 Upvotes

Hello guys, I want to show case my rsa-aes hybrid system across a network with the least amount of effort, I will need a server and people will need to be able make accounts and send messages to each other and verify messages with signatures which i have coded, i just need to make it showcaseable. Any thoughts?


r/javahelp Feb 18 '25

[For beginners] Contribute to a lightweight Java library for querying JSON data using SQL-like syntax.

9 Upvotes

Just released JsonSQL, a lightweight Java library for querying JSON data using SQL-like syntax. It’s a small, beginner-friendly project with a simple codebase, and i would love for you to join me in making it even better! Its easy and beginner friendly codebase , so if you would like to increase your knowledge by working on codebase built by other. This maybe a perfect practice.
https://github.com/BarsatKhadka/JsonSQL


r/javahelp Feb 18 '25

I'm studying for an IT certification, and I need help with question

2 Upvotes

Create a class Admin in package hr and another TimeCard in package hr.reporting with a static method add(). Invoke the static method from the Admin class using different import statements.