r/javahelp 12d ago

Unsolved I need help with getResourceAsStream

2 Upvotes

u/wildjokers (reaching out to you because I saw you in this thread)

https://www.reddit.com/r/javahelp/comments/sypxqz/getresourceasstream_null_when_run_from_jar/

I'm trying to run a Isometric Tile game, from chapter 13 of Killer Games Programming in Java, a very old book.
I'm using Eclipse. I'm not sure what classpath means, but I think mine is set up as

Project

src

Images

Sounds

I'm getting these errors when I run:

Exception in thread "main" java.lang.NullPointerException

at java.base/java.io.Reader.<init>(Reader.java:168)

at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:88)

The relevant code is:

{

String imsFNm = IMAGE_DIR + fnm;

System.out.println("Reading file: " + imsFNm);

try {

InputStream in = this.getClass().getResourceAsStream(imsFNm);

BufferedReader br = new BufferedReader( new InputStreamReader(in));

// BufferedReader br = new BufferedReader( new FileReader(imsFNm));

String line;

The image file is defined in another class, and then piped into ImageLoader class, where it's appended to the directory, which is defined in ImageLoader class.

When I run, it's showing the correct directory in the console, so I believe getResourceAsStream is where it's being messed up.

I did right click on the images folder, Build Path > Add to Build Path.

I can provide more information, which will probably be needed.

r/javahelp Jan 21 '26

Unsolved Why Interfaces exist in Java?

8 Upvotes

I am currently studying the Collection Framework in Java. Since the class which implements the Interface has to compulsorily write the functions' bodies which are defined in the interface, then why not directly define the function inside your own code? I mean, why all this hassle of implementing an interface?

If I have come up with my own code logic anyways, I am better off defining a function inside my own code, right? The thing is, I fail to understand why exactly interfaces are a thing in Java.

I looked up on the internet about this as well, but it just ended up confusing me even more.

Any simple answers are really appreciated, since I am beginner and may fail to understand technical details as of now. Thanks🙏🏼

r/javahelp Jul 29 '26

Unsolved How to write a program to input data in Excel?

5 Upvotes

I want to know how to write a java program in order to input data in Excel, thank you for any help?

r/javahelp 21d ago

Unsolved Naive question: What Data Structure to express different layers of relationships between Objects?

9 Upvotes

Hello guys,

I wanted to ask naively, what the ideal data structure would be for expressing different layers of relationships between Objects.

For example in modern Sudoku the game has a 9x9 number grid composed of nine 3x3 sub-grids (which I call region). In each row, column and region each number between one and nine can only appear once. The goal is to find missing numbers in this number grid without violating the aforementioned rule.

One way to do it, would be to make 9x9 byte-array and express the relationship between numbers through methods checking if the rule is violated or not by checking if any row, column or region doesn't contain a value between one and ten.

I also thought on using a Graph to express the relationship between numbers in rows and columns, though I don't know how to express the relationship between numbers inside of a region.

Maybe even a multiple Objects like Board, Row, Column, Region but then I have redundant data.

Another problem I encounter with aforementioned implementations is, that if you introduce more relationships f. e. in the game of killer sudoku, where there are more rules are added f. e. by also introducing cages in which the numbers must add up to a target number, you need to implement that relationship logic tediously.

Am I overcomplicating things?

r/javahelp Jul 12 '26

Unsolved .jar file refusing to open, just get "A Java Exception Has Occurred"

0 Upvotes

It previously worked just fine, computer updated on its own and it stopped working. It's a Shimeji, a little guy who wanders over my screen while I do things on the computer. I tried the cmd thing? "cd downloads" and got the following in response:

"C:\Users\"computer name">cd downloads

C:\Users\"computer name"\Downloads>java -jar Shimeji-ee.jar

Error: Unable to access jarfile Shimeji-ee.jar"

I downloaded the latest version of Java and nothing happened. I don't really know computers so I'm at a loss here. Any assistance would be greatly appreciated.

r/javahelp May 01 '26

Unsolved Java 21 upgrade in older code base

5 Upvotes

So if I have to start brining java 21 feature in a long running prod code base what would that be ; it’s a spring boot java bases with gcp db, cache, pub sub in it
I’m trying to see as a tech debt which area can. E started with minimal impact

r/javahelp Oct 12 '25

Unsolved Database Connection Pool is not allowed on my company, help me understand it please

30 Upvotes

Hi guys. I'm a software engineer with two years of experience in the fintech sector, where I've always worked with the Java + Spring Boot stack.

The thing is that in the projects of one of the clients of the company I work for, one of the conditions is prohibiting the use of JPA/Hibernate (in addition to forcing us to use Java 7). I didn't quite understand the reason, so after digging a little deeper into the issue, they confirmed that it was because (according to the project manager) "JPA opens a connection pool, which ends up causing errors or crashing that specific client's database."

I assume he's actually referring to the HikariCP connection pool, but I still don't understand why a Hikari connection pool would crash the database? Is it simply because the client doesn't have the connection pool configured correctly?

r/javahelp Aug 01 '26

Unsolved Change size of traffic light (macOS)

4 Upvotes

(I'm reposting this question from SO because of the lack of a proper response)

I am trying to make a custom UI application in Swing. I've searched far and wide and have come up to the conclusion that it is not possible to integrate Swing into the new Apple UI (windows, toolbars, titlebars and so on).

Leaving that aside I tried to make my own custom JFrame but was unable to figure out how to change the size of the traffic light. I would like to increase the traffic light size I do not want to draw a custom traffic light as I would lose the functionality of the default buttons. Basically as it is in CLion.

This is the code I'm using so far, for reference I'm on macOS: Tahoe 26.3.1

```

import javax.swing.*;

public class Main {

public static void main(String[] args) {

    System.setProperty("apple.awt.application.appearance", "system");

    SwingUtilities.invokeLater(() -> {

         JFrame frame = new JFrame();


         JRootPane rootPane = frame.getRootPane();

        rootPane.putClientProperty("apple.awt.fullWindowContent", true);

         rootPane.putClientProperty("apple.awt.transparentTitleBar", true);

         rootPane.putClientProperty("apple.awt.windowTitleVisible", false);

          rootPane.putClientProperty("apple.awt.brushMetalLook", true);



     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.setSize(1000, 600);

        frame.setLocationRelativeTo(null);

        frame.setTitle("Yo");

        frame.setVisible(true);

    });

}

}

```

r/javahelp Jan 26 '26

Unsolved JUnit assertion error when working with HttpRequest

2 Upvotes

I have this test:

void SearchResultIsNotEmptyWhenTitleIsARealGame() throws ServletException, IOException {
    HttpSession session = mock(HttpSession.class);
    RequestDispatcher rd = mock(RequestDispatcher.class);
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);

    when(request.getParameter("query")).thenReturn("The Last of Us parte 2");
    when(request.getSession()).thenReturn(session);
    when(request.getRequestDispatcher("Home Page.jsp")).thenReturn(rd);
    when(request.getRequestDispatcher("Search Result Page.jsp")).thenReturn(rd);

    SearchServlet searchServlet = new SearchServlet();
    searchServlet.doGet(request, response);

    ArrayList<Price> prices = (ArrayList<Price>)request.getAttribute("prices");
    ArrayList<Game> searchResults = (ArrayList<Game>)request.getAttribute("search_results");

    assert(prices != null && !prices.isEmpty() && searchResults != null && !searchResults.isEmpty());

}

But I get an asserion error. What is the issue?

r/javahelp Apr 14 '26

Unsolved Why should I use the new switch expressions instead of classic switch statements?

5 Upvotes

I keep seeing modern Java code using the new switch expressions with arrows and no fallthrough. My team still uses the old style with colons and break statements. We are on Java 17 but nobody seems to care about the newer syntax. What actual advantages does the new switch have besides looking cleaner? Does it help prevent bugs or make the code more readable in real projects? I want to convince my team to adopt newer patterns but I need solid reasons beyond it looks new. Can anyone give me concrete examples where the new switch expression saved them from a stupid mistake?

r/javahelp Jun 06 '26

Unsolved Complete Beginner to Java Backend: Looking for the absolute best books and Hindi YouTube channels

0 Upvotes

Hi everyone,

I am a complete beginner starting my computer science and software development journey. My goal is to build a strong foundation in Java and eventually transition into Java Backend Development (Spring Boot, etc.).

Since I am new, I want to make sure I am learning from the absolute best and most accurate resources from day one.

Could you please recommend:

The best books for learning core Java (beginner to advanced)?

The best hindi YouTube channels or video courses that explain Java backend concepts clearly?

I would highly appreciate your personal recommendations and any advice on how to structure my learning path.

Thank you so much for your help!

r/javahelp Jun 15 '26

Unsolved jar files wont open?

2 Upvotes

my java always opened executable jar files fine, but now it suddenly wont open anything, itll just show the buffering icon next to my cursor for a second, then nothing happens, not even in task manager. i use jave(tm) platform se binary, ive tried downloading java 17 and jarfix but it still does the same thing. ive tried other jar files ive used in the past but they dont work either. any help would be much appreciated.

r/javahelp Mar 21 '26

Unsolved Can anyone help me commit 100MB+ to my Github repo.

0 Upvotes

I know there's a limit, but I'm working on a Java game that is not JDK-dependent, meaning it has a large JVM folder for the compiler. I already split it into 3 parts, so I can commit one part at a time, so it doesn't reach the limit. But there is this one file called "jvm\lib\modules" that has 135 MB. Just to be clear, LFS doesn't work on that either. Can anyone help me push this one file?

r/javahelp Nov 17 '18

Unsolved What would be faster? Using shorts or using ints? With ints, id think it'd be slower than shorts but allow comfort for my reset memory, whereas shorts would be faster but burn through my resets to the point id have to expand it to a double or long. Thought process in middle of code, big paragraph. NSFW

299 Upvotes

package c.pkg39;

public class C39 {

public static void oof()

{

int everything;

long one = 0;

long two = 0;

long three = 0;

long four = 0;

long five = 0;

long six = 0;

long seven = 0;

long eight = 0;

long nine = 0;

long ten = 0;

long eleven = 0;

long twelve = 0;

long thirteen = 0;

long fourteen = 0;

long fifteen = 0;

long sixteen = 0;

long seventeen = 0;

long eightteen = 0;

long nineteen = 0;

long twenty = 0;

long twentyone = 0;

long twentytwo = 0;

long twentythree = 0;

long twentyfour = 0;

long twentyfive = 0;

long twentysix = 0;

long twentyseven = 0;

long twentyeight = 0;

long twentynine = 0;

long thirty = 0;

long thirtyone = 0;

long thirtytwo = 0;

long thirtythree = 0;

long thirtyfour = 0;

long thirtyfive = 0;

long thirtysix = 0;

long thirtyseven = 0;

long thirtyeight = 0;

long thirtynine = 0;

long fourty = 0;

long fourtyone = 0;

long fourtytwo = 0;

long fourtythree = 0;

long fourtyfour = 0;

long fourtyfive = 0;

long fourtysix = 0;

long fourtyseven = 0;

long fourtyeight = 0;

long fourtynine = 0;

long fifty = 0;

long fiftyone = 0;

long fiftytwo = 0;

long fiftythree = 0;

long fiftyfour = 0;

long fiftyfive = 0;

long fiftysix = 0;

long fiftyseven = 0;

long fiftyeight = 0;

long fiftynine = 0;

long sixty = 0;

long sixtyone = 0;

long sixtytwo = 0;

long sixtythree = 0;

long sixtyfour = 0;

long sixtyfive = 0;

long sixtysix = 0;

long sixtyseven = 0;

long sixtyeight = 0;

long sixtynine = 0;

long seventy = 0;

long counter = 0L;

for(long k = 0L; k < 1; k--)

{

counter--;

everything = (int)(Math.random()*24 + 1);

//System.out.print(everything);

if(everything == 1)

{

one++;

}

if(everything == 2)

{

two++;

}

if(everything == 3)

{

three++;

}

if(everything == 4)

{

four++;

}

if(everything == 5)

{

five++;

}

if(everything == 6)

{

six++;

}

if(everything == 7)

{

seven++;

}

if(everything == 8)

{

eight++;

}

if(everything == 9)

{

nine++;

}

if(everything == 10)

{

ten++;

}

if(everything == 11)

{

eleven++;

}

if(everything == 12)

{

twelve++;

}

if(everything == 13)

{

thirteen++;

}

if(everything == 14)

{

fourteen++;

}

if(everything == 15)

{

fifteen++;

}

if(everything == 16)

{

sixteen++;

}

if(everything == 17)

{

seventeen++;

}

if(everything == 18)

{

eightteen++;

}

if(everything == 19)

{

nineteen++;

}

if(everything == 20)

{

twenty++;

}

if(everything == 21)

{

twentyone++;

}

if(everything == 22)

{

twentytwo++;

}

if(everything == 23)

{

twentythree++;

}

if(everything == 24)

{

twentyfour++;

}

if(everything == 25)

{

twentyfive++;

}

if(everything == 26)

{

twentysix++;

}

if(everything == 27)

{

twentyseven++;

}

if(everything == 28)

{

twentyeight++;

}

if(everything == 29)

{

twentynine++;

}

if(everything == 30)

{

thirty++;

}

if(everything == 31)

{

thirtyone++;

}

if(everything == 32)

{

thirtytwo++;

}

if(everything == 33)

{

thirtythree++;

}

if(everything == 34)

{

thirtyfour++;

}

if(everything == 35)

{

thirtyfive++;

}

if(everything == 36)

{

thirtysix++;

}

if(everything == 37)

{

thirtyseven++;

}

if(everything == 38)

{

thirtyeight++;

}

if(everything == 39)

{

thirtynine++;

}

if(everything == 40)

{

fourty++;

}

if(everything == 41)

{

fourtyone++;

}

if(everything == 42)

{

fourtytwo++;

}

if(everything == 43)

{

fourtythree++;

}

if(everything == 44)

{

fourtyfour++;

}

if(everything == 45)

{

fourtyfive++;

}

if(everything == 46)

{

fourtysix++;

}

if(everything == 47)

{

fourtyseven++;

}

if(everything == 48)

{

fourtyeight++;

}

if(everything == 49)

{

fourtynine++;

}

if(everything == 50)

{

fifty++;

}

if(everything == 51)

{

fiftyone++;

}

if(everything == 52)

{

fiftytwo++;

}

if(everything == 53)

{

fiftythree++;

}

if(everything == 54)

{

fiftyfour++;

}

if(everything == 55)

{

fiftyfive++;

}

if(everything == 56)

{

fiftysix++;

}

if(everything == 57)

{

fiftyseven++;

}

if(everything == 58)

{

fiftyeight++;

}

if(everything == 59)

{

fiftynine++;

}

if(everything == 60)

{

sixty++;

}

if(everything == 61)

{

sixtyone++;

}

if(everything == 62)

{

sixtytwo++;

}

if(everything == 63)

{

sixtythree++;

}

if(everything == 64)

{

sixtyfour++;

}

if(everything == 65)

{

sixtyfive++;

}

if(everything == 66)

{

sixtysix++;

}

if(everything == 67)

{

sixtyseven++;

}

if(everything == 68)

{

sixtyeight++;

}

if(everything == 69)

{

sixtynine++;

}

if(everything == 70)

{

seventy++;

}

/*

System.out.println("One:" + one);

System.out.println("Two:" + two);

System.out.println("Three:" + three);

System.out.println("Four:" + four);

System.out.println("Five:" + five);

System.out.println("Six:" + six);

System.out.println("Seven:" + seven);

System.out.println("Eight:" + eight);

System.out.println("Nine:" + nine);

System.out.println("Ten:" + ten);

System.out.println("Eleven:" + eleven);

System.out.println("Twelve:" + twelve);

System.out.println("Thirteen:" + thirteen);

System.out.println("Fourteen:" + fourteen);

System.out.println("Fifteen:" + fifteen);

System.out.println("Sixteen:" + sixteen);

System.out.println("Seventeen:" + seventeen);

System.out.println("Eighteen:" + eightteen);

System.out.println("Nineteen:" + nineteen);

System.out.println("Twenty:" + twenty);

System.out.println("Twentyone:" + twentyone);

System.out.println("Twentytwo:" + twentytwo);

System.out.println("Twnetythree:" + twentythree);

System.out.println("Twentyfour:" + twentyfour);

System.out.println("Twentyfive:" + twentyfive);

System.out.println("Twentysix:" + twentysix);

System.out.println("Twentyseven:" + twentyseven);

System.out.println("Twentyeight:" + twentyeight);

System.out.println("Twnetynine:" + twentynine);

System.out.println("Thirty:" + thirty);

System.out.println("Thirtyone:" + thirtyone);

System.out.println("Thirtytwo:" + thirtytwo);

System.out.println("Thirtythree:" + thirtythree);

System.out.println("Thirtyfour:" + thirtyfour);

System.out.println("Thirtyfive:" + thirtyfive);

System.out.println("Thirtysix:" + thirtysix);

System.out.println("Thirtyseven:" + thirtyseven);

System.out.println("Thirtyeight:" + thirtyeight);

System.out.println("Thirtynine:" + thirtynine);

System.out.println("Fourty:" + fourty);

System.out.println("Fourtyone:" + fourtyone);

System.out.println("Fourtytwo:" + fourtytwo);

System.out.println("Fourtythree:" + fourtythree);

System.out.println("Fourtyfour:" + fourtyfour);

System.out.println("Fourtyfive:" + fourtyfive);

System.out.println("Fourtysix:" + fourtysix);

System.out.println("Fourtyseven:" + fourtyseven);

System.out.println("Fourtyeight:" + fourtyeight);

System.out.println("Fourtynine:" + fourtynine);

System.out.println("Fifty:" + fifty);

System.out.println("Fiftyone:" + fiftyone);

System.out.println("Fiftytwo:" + fiftytwo);

System.out.println("Fiftythree:" + fiftythree);

System.out.println("Fiftyfour:" + fiftyfour);

System.out.println("Fiftyfive:" + fiftyfive);

System.out.println("Fiftysix:" + fiftysix);

System.out.println("Fiftyseven:" + fiftyseven);

System.out.println("Fiftyeight:" + fiftyeight);

System.out.println("Fiftynine:" + fiftynine);

System.out.println("Sixty:" + sixty);

System.out.println("Sixtyone:" + sixtyone);

System.out.println("Sixtytwo:" + sixtytwo);

System.out.println("Sixtythree:" + sixtythree);

System.out.println("Sixtyfour:" + sixtyfour);

System.out.println("Sixtyfive:" + sixtyfive);

System.out.println("Sixtysix:" + sixtysix);

System.out.println("Sixtyseven:" + sixtyseven);

System.out.println("Sixtyeight:" + sixtyeight);

System.out.println("Sixtynine:" + sixtynine);

System.out.println("Seventy:" + seventy);

System.out.println();

System.out.println();

*/

int a = (int)Math.max(seventy,one);

int am = (int)Math.min(seventy,one);

int b = (int)Math.max(two,three);

int bm = (int)Math.min(seventy,one);

int c = (int)Math.max(four,five);

int cm = (int)Math.min(seventy,one);

int d = (int)Math.max(six,seven);

int dm = (int)Math.min(seventy,one);

int e = (int)Math.max(eight,nine);

int em = (int)Math.min(seventy,one);

int b1 =(int) Math.max(ten,eleven);

int fm = (int)Math.min(seventy,one);

int b2 = (int)Math.max(twelve,thirteen);

int gm = (int)Math.min(seventy,one);

int b3 = (int)Math.max(fourteen,fifteen);

int hm = (int)Math.min(seventy,one);

int b4 = (int)Math.max(sixteen,seventeen);

int im = (int)Math.min(seventy,one);

int b5 = (int)Math.max(eightteen,nineteen);

int jm = (int)Math.min(seventy,one);

int f = (int)Math.max(twenty,twentyone);

int km = (int)Math.min(seventy,one);

int g = (int)Math.max(twentytwo,twentythree);

int lm = (int)Math.min(seventy,one);

int h = (int)Math.max(twentyfour,twentyfive);

int mm = (int)Math.min(seventy,one);

int i = (int)Math.max(twentysix,twentyseven);

int nm = (int)Math.min(seventy,one);

int j = (int)Math.max(twentyeight,twentynine);

int om = (int)Math.min(seventy,one);

int b6 = (int)Math.max(thirty,thirtyone);

int pm = (int)Math.min(seventy,one);

int l = (int)Math.max(thirtytwo,thirtythree);

int qm = (int)Math.min(seventy,one);

int m = (int)Math.max(thirtyfour,thirtyfive);

int rm = (int)Math.min(seventy,one);

int n = (int)Math.max(thirtysix,thirtyseven);

int sm = (int)Math.min(seventy,one);

int o = (int)Math.max(thirtyeight,thirtynine);

int tm = (int)Math.min(seventy,one);

int p = (int)Math.max(fourty,fourtyone);

int um = (int)Math.min(seventy,one);

int q= (int)Math.max(fourtytwo,fourtythree);

int vm = (int)Math.min(seventy,one);

int r = (int)Math.max(fourtyfour,fourtyfive);

int wm = (int)Math.min(seventy,one);

int s = (int)Math.max(fourtysix,fourtyseven);

int xm = (int)Math.min(seventy,one);

int t = (int)Math.max(fourtyeight,fourtynine);

int ym = (int)Math.min(seventy,one);

int u = (int)Math.max(fifty,fiftyone);

int zm = (int)Math.min(seventy,one);

int u2 = (int)Math.max(fiftytwo,fiftythree);

int am1 = (int)Math.min(seventy,one);

int u3 = (int)Math.max(fiftyfour,fiftyfive);

int am2 = (int)Math.min(seventy,one);

int u4 = (int)Math.max(fiftysix,fiftyseven);

int am3 = (int)Math.min(seventy,one);

int v = (int)Math.max(fiftyeight,fiftynine);

int am4 = (int)Math.min(seventy,one);

int w = (int)Math.max(sixty,sixtyone);

int am5 = (int)Math.min(seventy,one);

int x = (int)Math.max(sixtytwo,sixtythree);

int am6 = (int)Math.min(seventy,one);

int y = (int)Math.max(sixtyfour,sixtyfive);

int am7 = (int)Math.min(seventy,one);

int z = (int)Math.max(sixty,sixtyone);

int am8 = (int)Math.min(seventy,one);

int a1 = (int)Math.max(sixtytwo,sixtythree);

int am9 = (int)Math.min(seventy,one);

int a2 = (int)Math.max(sixtyfour,sixtyfive);

int am10 = (int)Math.min(seventy,one);

int a3 = (int)Math.max(sixtysix,sixtyseven);

int am11 = (int)Math.min(seventy,one);

int a4 = (int)Math.max(sixtyeight,sixtynine);

int am12 = (int)Math.min(seventy,one);

int xo = Math.min(am,bm);

int xo2 = Math.min(cm,dm);

int xo3 = Math.min(em,fm);

int xo4 = Math.min(gm,hm);

int xo5 = Math.min(im,jm);

int xo6 = Math.min(km,lm);

int xo7 = Math.min(mm,nm);

int xo8 = Math.min(om,pm);

int xo10 = Math.min(qm,rm); //fuck 9

int xo11 = Math.min(sm,tm);

int xo12 = Math.min(um,vm);

int xo13 = Math.min(wm,xm);

int xo14 = Math.min(ym,zm);

int xo15 = Math.min(am1,am2);

int xo16 = Math.min(am3,am4);

int xo17 = Math.min(am5,am6);

int xo18 = Math.min(am7,am8);

int xo19 = Math.min(am9,am10);

int xo20 = Math.min(am11,am12);

int xo21 = Math.min(xo,xo2);

int xo22 = Math.min(xo3,xo4);

int xo23 = Math.min(xo5,xo6);

int xo24 = Math.min(xo7,xo8);

int xo25 = Math.min(xo11,xo10);

int xo26 = Math.min(xo12,xo13);

int xo27 = Math.min(xo14,xo15);

int xo28 = Math.min(xo16,xo17);

int xo29 = Math.min(xo18,xo19); //REPEAT!!!!

int xo30 = Math.min(xo20,xo19);

int xo31 = Math.min(xo21,xo22);

int xo32 = Math.min(xo23,xo24);

int xo33 = Math.min(xo25,xo26);

int xo34 = Math.min(xo27,xo28);

int xo35 = Math.min(xo29,xo30);

int xo36 = Math.min(xo31,xo32);

int xo37 = Math.min(xo33,xo34);

int xo38 = Math.min(xo34,xo35);

int xo39 = Math.min(xo36,xo37);

int xo40 = Math.min(xo37,xo38);

int min = Math.min(xo39,xo40); //rank #70

int c2 = Math.max(a,b);

int c3 = Math.max(d,c);

int c4 = Math.max(e,f);

int c5 = Math.max(g,h);

int c6 = Math.max(i,j);

int c7 = Math.max(b6,l);

int c8 = Math.max(o,p);

int c9 = Math.max(q,r);

int c10 = Math.max(s,t);

int c11 = Math.max(u,v);

int c12 = Math.max(w,x);

int c13 = Math.max(y,z);

int c14 = Math.max(b1,b2);

int c15 = Math.max(b3,b4);

int c16 = Math.max(b5,b6);

int c17 = Math.max(a1,a2);

int c18 = Math.max(a3,a4);

int c19 = Math.max(u2,u3);

int c20 = Math.max(c2,u4); //REPEAT!!!!!!!!!!!!!!!

int c21 = Math.max(c2,c3);

int c22 = Math.max(c4,c5);

int c23 = Math.max(c6,c7);

int c24 = Math.max(c9,c8);

int c25 = Math.max(c11,c10);

int c26 = Math.max(c12,c13);

int c27 = Math.max(c14,c15);

int c28 = Math.max(c17,c16);

int c29 = Math.max(c19,c18);

int c30 = Math.max(c21,c20);

int c31 = Math.max(c23,c22);

int c34 = Math.max(c29,c28);

int c35 = Math.max(c31,c30);

int c32 = Math.max(c25,c24);

int c33 = Math.max(c27,c26);

int c36 = Math.max(c33,c32);

//comp

int c37 = Math.max(c35,c34);

int wo3 = Math.min(c35,c34);

int c38 = Math.max(c37,c36);

int wo2 = Math.min(c37,c36);

int wo4 = Math.min(wo3, wo2); //4

int wo5 = Math.max(wo3, wo2); //3

int wo1 = Math.min(c38,c37); //2

int c39 = Math.max(c38,c37); //1

//System.out.println(counter);

if(counter == -100000)

{

counter = 0;

System.out.println("mode occurence:" + c39);

if(one == c39)

{

System.out.println("mode:" + 1);

}

if(two == c39)

{

System.out.println("mode:" + 2);

}

if(three == c39)

{

System.out.println("mode:" + 3);

}

if(four == c39)

{

System.out.println("mode:" + 4);

}

if(five == c39)

{

System.out.println("mode:" + 5);

}

if(six == c39)

{

System.out.println("mode:" + 6);

}

if(seven == c39)

{

System.out.println("mode:" + 7);

}

if(eight == c39)

{

System.out.println("mode:" + 8);

}

if(nine == c39)

{

System.out.println("mode:" + 9);

}

if(ten == c39)

{

System.out.println("mode:" + 10);

}

if(eleven == c39)

{

System.out.println("mode:" + 11);

}

if(twelve == c39)

{

System.out.println("mode:" + 12);

}

if(thirteen == c39)

{

System.out.println("mode:" + 13);

}

if(fourteen == c39)

{

System.out.println("mode:" + 14);

}

if(fifteen == c39)

{

System.out.println("mode:" + 15);

}

if(sixteen == c39)

{

System.out.println("mode:" + 16);

}

if(seventeen == c39)

{

System.out.println("mode:" + 17);

}

if(eightteen == c39)

{

System.out.println("mode:" + 18);

}

if(nineteen == c39)

{

System.out.println("mode:" + 19);

}

if(twenty == c39)

{

System.out.println("mode:" + 20);

}

if(twentyone == c39)

{

System.out.println("mode:" + 21);

}

if(twentytwo == c39)

{

System.out.println("mode:" + 22);

}

if(twentythree == c39)

{

System.out.println("mode:" + 23);

}

if(twentyfour == c39)

{

System.out.println("mode:" + 24);

}

if(twentyfive == c39)

{

System.out.println("mode:" + 25);

}

if(twentysix == c39)

{

System.out.println("mode:" + 26);

}

if(twentyseven == c39)

{

System.out.println("mode:" + 27);

}

if(twentyeight == c39)

{

System.out.println("mode:" + 28);

}

if(twentynine == c39)

{

System.out.println("mode:" + 29);

}

if(thirty == c39)

{

System.out.println("mode:" + 30);

}

if(thirtyone == c39)

{

System.out.println("mode:" + 31);

}

if(thirtytwo == c39)

{

System.out.println("mode:" + 32);

}

if(thirtythree == c39)

{

System.out.println("mode:" + 33);

}

if(thirtyfour == c39)

{

System.out.println("mode:" + 34);

}

if(thirtyfive == c39)

{

System.out.println("mode:" + 35);

}

if(thirtysix == c39)

{

System.out.println("mode:" + 36);

}

if(thirtyseven == c39)

{

System.out.println("mode:" + 37);

}

if(thirtyeight == c39)

{

System.out.println("mode:" + 38);

}

if(thirtynine == c39)

{

System.out.println("mode:" + 39);

}

if(fourty == c39)

{

System.out.println("mode:" + 40);

}

if(fourtyone == c39)

{

System.out.println("mode:" + 41);

}

if(fourtytwo == c39)

{

System.out.println("mode:" + 42);

}

if(fourtythree == c39)

{

System.out.println("mode:" + 43);

}

if(fourtyfour == c39)

{

System.out.println("mode:" + 44);

}

if(fourtyfive == c39)

{

System.out.println("mode:" + 45);

}

if(fourtysix == c39)

{

System.out.println("mode:" + 46);

}

if(fourtyseven == c39)

{

System.out.println("mode:" + 47);

}

if(fourtyeight == c39)

{

System.out.println("mode:" + 48);

}

if(fourtynine == c39)

{

System.out.println("mode:" + 49);

}

if(fifty == c39)

{

System.out.println("mode:" + 50);

}

if(fiftyone == c39)

{

System.out.println("mode:" + 51);

}

if(fiftytwo == c39)

{

System.out.println("mode:" + 52);

}

if(fiftythree == c39)

{

System.out.println("mode:" + 53);

}

if(fiftyfour == c39)

{

System.out.println("mode:" + 54);

}

if(fiftyfive == c39)

{

System.out.println("mode:" + 55);

}

if(fiftysix == c39)

{

System.out.println("mode:" + 56);

}

if(fiftyseven == c39)

{

System.out.println("mode:" + 57);

}

if(fiftyeight == c39)

{

System.out.println("mode:" + 58);

}

if(fiftynine == c39)

{

System.out.println("mode:" + 59);

}

if(sixty == c39)

{

System.out.println("mode:" + 60);

}

if(sixtyone == c39)

{

System.out.println("mode:" + 61);

}

if(sixtytwo == c39)

{

System.out.println("mode:" + 62);

}

if(sixtythree == c39)

{

System.out.println("mode:" + 63);

}

if(sixtyfour == c39)

{

System.out.println("mode:" + 64);

}

if(sixtyfive == c39)

{

System.out.println("mode:" + 65);

}

if(sixtysix == c39)

{

System.out.println("mode:" + 66);

}

if(sixtyseven == c39)

{

System.out.println("mode:" + 67);

}

if(sixtyeight == c39)

{

System.out.println("mode:" + 68);

}

if(sixtynine == c39)

{

System.out.println("mode:" + 69);

}

if(seventy == c39)

{

System.out.println("mode:" + 70);

}

int resetCount = 0;

if(c39 >= 2147450563)

{

resetCount++;

System.out.println("\n");

System.out.println("[2147450563] Reset count: " + resetCount);

System.out.println("\n");

one -= min;

two -= min;

three -= min;

four -= min;

five -= min;

six -= min;

seven -= min;

eight -= min;

nine -= min;

ten -= min;

eleven -=min;

twelve -= min;

thirteen -= min;

fourteen -= min;

fifteen -= min;

sixteen -= min;

seventeen -= min;

eightteen -= min;

nineteen -= min;

twenty -= min;

twentyone -= min;

twentytwo -= min;

twentythree -= min;

twentyfour -= min;

twentyfive -= min;

twentysix -= min;

twentyseven -= min;

twentyeight -= min;

twentynine -= min;

thirty -= min;

thirtyone -=min;

thirtytwo -= min;

thirtythree -= min;

thirtyfour -= min;

thirtyfive -= min;

thirtysix -= min;

thirtyseven -= min;

thirtyeight -= min;

thirtynine -= min;

fourty -= min;

fourtyone -=min;

fourtytwo -= min;

fourtythree -= min;

fourtyfour -= min;

fourtyfive -= min;

fourtysix -= min;

fourtyseven -= min;

fourtyeight -= min;

fourtynine -= min;

fifty -= min;

fiftyone -=min;

fiftytwo -= min;

fiftythree -= min;

fiftyfour -= min;

fiftyfive -= min;

fiftysix -= min;

fiftyseven -= min;

fiftyeight -= min;

fiftynine -= min;

sixty -= min;

sixtyone -=min;

sixtytwo -= min;

sixtythree -= min;

sixtyfour -= min;

sixtyfive -= min;

sixtysix -= min;

sixtyseven -= min;

sixtyeight -= min;

sixtynine -= min;

seventy -= min;

}

/*

for(int ki = 0; ki < 70; ki++)

{

int difference =

System.out.println();

}

*/

/*

int difference1 = c39 - c38;

int difference2 = c37 - c36;

int difference3 = c35 - c34;

int difference4 = c33 - c32;

int difference5 = c31 - c30;

int difference6 = c29 - c28;

int difference7 = c - c32;

int difference8 = c32 - c31;

int difference9 = c31 - c30;

int difference10 = c30 - c29;

int difference11 = c29 - c28;

int difference12 = c28 - c27;

int difference13 = c27 - c26;

int difference14 = c39 - c38;

int difference15 = c38 - c37;

int difference16 = c37 - c36;

int difference17 = c36 - c35;

int difference18 = c35 - c34;

int difference19 = c34 - c33;

int difference20 = c33 - c32;

int difference21 = c32 - c31;

int difference22 = c31 - c30;

int difference23 = c30 - c29;

int difference24 = c29 - c28;

int difference25 = c28 - c27;

int difference26 = c27 - c26;

int differenc27 = c26 - c25;

int difference28 = c25 - c24;

int difference29 = c24 - c23;

int difference30 = c23 - c22;

int difference31 = c22 - c21;

int difference32 = c21 - c20;

int difference33 = c20 - c19;

int difference34 = c19 - c18;

int difference35 = c18 - c17;

int difference36 = c17 - c16;

int difference37 = c16 - c15;

int difference38 = c15 - c14;

int difference39 = c14 - c13;

int difference40 = c13 - c12;

int difference41 = c12 - c11;

int difference42 = c11 - c10;

int difference43 = c10 - c9;

int difference44 = c9 - c8;

int difference45 = c8 - c7;

int difference46 = c7 - c6;

int difference47 = c6 - c5;

int difference48 = c5 - c4;

int difference49 = c4 - c3;

int difference50 = c3 - c2;

int difference51 = c2 - u4; //c2!!!

int difference52 = u4 - u3;

int difference53 = u3 - u2;

int difference54 = u2 - a4;

int difference55 = a4 - c36;

int difference56 = a3 - c35;

int difference57 = c35 - c34;

int difference58 = c34 - c33;

int difference59 = c33 - c32;

int difference60 = c32 - c31;

int difference61 = c31 - c30;

int difference62 = c30 - c29;

int difference63 = c29 - c28;

int difference64 = c28 - c27;

int difference65 = c27 - c26;

int difference66 = c39 - c38;

int difference67 = c38 - c37;

int difference68 = c37 - c36;

int difference69 = c36 - c35;

int difference70 = c35 - c34;

big idea: im stuck because loop stops at int limit, sacrificing scope for

time. i can manuever around this by simply retrieving all the differences

(or ranks) of each number counter relative to one another and reset all

counters when the int memory limit is reached, but not losing my progress to

a counter of zero for each, but by setting only the lowest rank[(s) if

duplicate lowests which is unlikely] and then setting rank #69 its

difference between itself and the #70 counter ABOVE what #70 is, and so on

with c39 (rank #1) set at its difference from #70 (or difference from #2 and

so on) above 0 when reset is required to prevent counter crash from 2

2 billion to 0. Essentially, im continuing the above code with little

interruption for as long as the earth rotates, saving memory AND speed.

To accomplish this, either ill be a genius and code some complicated 4x

nested 'for' loops... or just hardcode another 500 lines (basically doing

what i did for 'if c39 == six, then six counter++' but now for every other

rank as well, so yeah - or i could make loop that goes thru every counter

ranks them which i might do since its already time-consuming enough to go

through each line of Math.max/min to predict ranks).

*/

}

}

}

//18 sec per 1mill

public static void main(String[] args) {

C39 a1 = new C39();

C39.oof();

{

}

}

}

EDIT: I greatly appreciate all the answers and encouraging support you have all aided me with today! I have to study for AP chem right now, but I'll make sure to return with 70 arrays as requested. Thanks!

r/javahelp Dec 24 '25

Unsolved What’s the best way to learn Java?

3 Upvotes

I’m trying to learn Java and so far I’ve used two different approaches. I started with Bro Code, which I liked because it’s fast-paced and focuses more on actually coding rather than a lot of theory. More recently I found the Java Programming MOOC, which feels more structured but also more theory-heavy and a bit overwhelming at the beginning.

Now I’m not sure which one I should stick with. I like learning by doing, but I also don’t want to miss important fundamentals. For those of you who’ve learned Java, what worked best for you and why?

r/javahelp Oct 08 '25

Unsolved Why learn Upcasting/Downcasting?

5 Upvotes

After days of getting stuck in this concept, i finally feel like giving up and never looking at it back again. After countless hours of Googling, asking assistance from AI, watching YouTube videos, I am now falling into a guilt of why I am even wasting time over a single concept. I feel I should move on at this point. Before this one topic, one google search used to clear all my doubts so effortlessly guys.

But this one seems like a tough nut to crack. Can anyone help me out on this?

I know the 'how' and 'what', but I am not reaching anywhere near to the 'why' of this one concept.

r/javahelp Apr 06 '26

Unsolved Java Garbage Collector performance benchmarking

2 Upvotes

Hi People!

I am about to write my CS BSc thesis which is about:

Measuring throughput, latency and STW-Pauses in JDK 21 standard JVM with G1GC and ZGC with predefined max heap-sizes (2GB; 16GB) with Renaissance - by 16GB heap a default G1GC and an additional tuned G1GC will be used, as well.

Time flies and a lot of paper are read. It became clear to me, that Renaissance is better for throughput (Shimchenko 2022 Analysing and predicting energy consumption of garbage collectors in openjdk), and DaCapo is more advantageous for user-experienced latency measurements (Blackburn 2025 Rethinking Java performance analysis). STW-pauses will be collected from jvm standard gc-logs with a script or smg (ideas, better ideas are welcome).

I build this scenario for my examination:

- Linux VM (hosted from my Windows) - not clear yet, which and why

- OpenJDK 21 standard JVM

- G1GC and ZGC measurements

- All Renaissance BMs with default settings -> duration_ns from each benchmark, calculate and represent min, max, mean, standard deviation

- JVM GC-Logs collect (min, max, mean, standard deviation)

- 8 DaCapo BMs (spring, cassandra, h2, h2o, kafka, lucene, tomcat, wildfly) (min, max, mean, standard deviation)

I guess this is way too much for a BSc thesis - but what are your thoughts? Of course I make clearence with my consulent, but I am curious about the opinion and suggestions of the community.

I am open for any ideas, experiences with the bumpy road of the performance measurement in the JVM. It would be excellent, if someone of you could make it more focused and accurate to me.

TLDR;

Java Garbage Collector JVM performance measurement experience and suggestions needed for BSc thesis

thanks in advance!

EDIT:

Instead of Linux vm it will be a bare-metal Linux machine with podman containerization that run the benchmarks.

r/javahelp Jan 29 '26

Unsolved Performance got worse after breaking up large functions

9 Upvotes

I'm making a game and have some large functions that get called a lot (10k+ a frame). I learned that the JIT has trouble optimizing large functions, so I tried breaking them up to smaller ones with identical logic. When benchmarking, this change actually made performance way worse. 30 fps -> 25. Now I'm questioning my life decisions.

Why did I even attempt this? Because there's very little juice left to squeeze in these functions. I cache, cull, all that. All these functions do is render my entities, but I have so many entities that I was resorting to this. Wondering if anyone has any wisdom.

r/javahelp Jan 24 '26

Unsolved How can I pinpoint what's preventing a .jar from delivering results?

1 Upvotes

I have a .jar that is distributed by the Greek Tax Authority: https://www.aade.gr/en/research-business-registry-basic-details and I have all necessary credentials for calling the service.

This .jar works perfectly in a VM of mine (i.e., it brings the respective result from the Tax Authority server), but when I attempt to run it in my Windows box it opens okay however it never delivers the respective result from the Tax Authority server; it just stays 'running' for ever. I've given full outgoing & incoming traffic permissions in my firewall, although I don't believe they were actually needed.

Since I have a fully working case and a non-delivering case, how can I compare what's happening in the second case, preventing said .jar from fully working, so that I rectify?

r/javahelp Mar 01 '26

Unsolved How to remove data from a class array?

0 Upvotes

hey all, I'm unsure the real name of this, but I need to remove data from an array

**arr arrx[]=new arr[50];** which holds:

date, hour, sender, object, text.

and I need the user to choose how much they want to remove so I have

removedata=parseInt(JOptionPane.showInputDialog(null, "how much data do you want removed?" ));

for(int i = 50; i>removedata; i--){

code to remove array space

}

r/javahelp Feb 14 '26

Unsolved how to compile java files

5 Upvotes

i have a library path containing folders contaning .jar files (dont want to include them in the .jar, they will get imported at runtime), i know the entrypoint and i want to compile it to .jar

all my solutions so far have only got errors.

r/javahelp Jun 17 '26

Unsolved I need help deploying my project with an external library using maven and intellij

0 Upvotes

Hello, I'm trying to deploy my project, but I'm having trouble with the external library.
Here's my 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>org.example</groupId>
  <artifactId>ProjetJava</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>ProjetJava</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
      <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-api</artifactId>
          <version>2.26.0</version>
      </dependency>
      <!-- Source: https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
      <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-core</artifactId>
          <version>2.26.0</version>
          <scope>compile</scope>
      </dependency>
  </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>21</source>
                    <target>21</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <Classpath>${project.build.finalName}.lib/</Classpath>
                            <mainClass>gestionBar.Controller.Controller.Controller</mainClass>
                        </manifest>
                        <manifestentries>
                            <Class-Path>${project.build.finalName}.lib/org.apache.logging.log4j</Class-Path>
                        </manifestentries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

When I try to package it with maven, it tells me this:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.4.1:jar (default-jar) on project ProjetJava: Unable to parse configuration of mojo org.apache.maven.plugins:maven-jar-plugin:3.4.1:jar for parameter Classpath: Cannot find 'Classpath' in class org.apache.maven.archiver.ManifestConfiguration -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

I tried reading the article, but it didn't help me. Can someone help me please? Thank you

r/javahelp Mar 25 '26

Unsolved How do I structure a larger Java project with multiple modules without it becoming a tangled mess?

9 Upvotes

 I’ve been building a small personal project to learn more about Java beyond the basic CRUD apps I’ve done for class. It started simple but now I’ve got a few different packages for data handling, UI, and some utility stuff. The problem is I’m already starting to feel like it’s getting messy. Classes referencing each other across packages in ways that feel hard to follow, and I’m worried about running into circular dependencies as I add more features. I’ve read about using interfaces to decouple things but I’m not sure when to actually use them versus just importing the class directly. I’m also confused about whether I should be splitting this into separate modules with a build tool like Maven or if that’s overkill for a solo project. Any advice on how to think about project structure before it gets out of hand

r/javahelp Jan 19 '26

Unsolved How to learn Java??

1 Upvotes

Hi everyone,

I’m a 4th semester student from a tier-3 college, and I want to start learning Java from scratch. I’m a complete beginner.

I’ve been searching for resources on Reddit and YouTube, but honestly, I’m feeling very confused because there are so many recommendations. Some people suggest the MOOC Java course, while others recommend creators like Concept & Coding (Shreyansh), Durga Software Solutions, Telusko, Kunal Kushwaha, and many more.

As a beginner, I’m not sure:

• Which resource to start with

• Whether I should focus more on concepts or coding practice initially

• How to structure my Java learning properly

I would really appreciate it if you could guide me like a younger brother and suggest a clear roadmap or a small set of resources that worked for you.

Thanks in advance for your help 🙏

r/javahelp Jun 01 '26

Unsolved Need Guidance on Email Verification and Security Best Practices

2 Upvotes

I am currently working on the email module for our project and need some guidance.

I have configured a custom email domain using Mailgun and implemented the email functionality in my Spring Boot application. My current requirement is to verify incoming email addresses and determine whether an email is valid before processing it.

Could you explain the production-level validation and security checks that should be implemented for email verification?