r/javahelp • • Aug 06 '19

Why do arrays in Java need to be the same type?

17 Upvotes

I heard that one of the reasons was to allow for constant time access, but I don't get how that's possible if you have a polymorphic array. In other words, if I had something like Doctor[] = new Doctor[4]; and I stored inside the array subtypes like Surgeon, Cardiologist, etc...how could I ensure constant time access if the subtypes had varying numbers of fields? (Ex...surgeon might add another 30 fields of it's own, and another 20 methods of its own).


r/javahelp • • Jul 22 '19

Which way of authentication is better and safer for Angular 8 with Spring Boot backend?

17 Upvotes

So, I searched the web and I found two popular ways to do it.

The first one is in the official Spring documentation: https://spring.io/guides/tutorials/spring-security-and-angular-js/

Second one is an Auth0 blog post: https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/

Both are outdated a little. The first maybe safer, because it is official, but seems a little complicated. The second one is using JWT, which is so popular.

What do you think, which way would you do and why?


r/javahelp • • Jul 19 '19

Java for Beginners

17 Upvotes

Are there any recommended communities here on reddit for a person who is just beginning to learn the java language?


r/javahelp • • Jul 12 '19

Understanding java concept of instantiating list of list of integers object as an arraylist

17 Upvotes

What is going on in this instantiation of List<List<Integer>> p = new ArrayList<>(); I forgot what this concept was called so googling didn't give good answers. I understand the left side part of it, literally saying what p is but not the right hand side part. Why wouldn't it be new ArrayList<ArrayList<>>(); ?


r/javahelp • • Jun 22 '19

do professional java applications use swing form designer to create GUI ?

17 Upvotes

I mean do softwares likes InteliJ which are made in Swing , code all GUI in code manully ?? or they use GUI desiner with like one provided with InteliJ with Drag-and-drop ??


r/javahelp • • Jun 17 '19

Is javax.swing still being used? If not, What would be an alternative?

17 Upvotes

It's been a while since I've worked on desktop after switching to Android. Just curious if there are any developers still use Swing, or what is being used instead.


r/javahelp • • May 29 '19

Best way to manage service layer and error handling in Java Spring?

17 Upvotes

Hey guys, I have an implementation question about the service layer in a Java Spring application. We are using the repository design pattern.

In the past, I would have the service layer make calls to the repository, handle mapping the returned entities to DTOs, and then return the DTO or list of DTOs from the service layer and put them in the payload in the controller.

However, at my current job everybody wraps the response from service layers in a result class. This result class includes the possible data of a generic type, as well as some fields like "hasError", "errorMessages", and "statusCode".

My question is, is this best practice? Would it not make more sense to use something like @ControllerAdvice in Spring, and throw an exception with an associated status code?

I think they did this because they wanted the response to always be the same structure, whether or not there was an error. However, I think it might be better practice to just look at the status code that is returned, and make a decision based on that. "errorMessages" and the other fields could just be included in the exception class.

I am curious your guys thoughts on this. I have found many examples using springs error handling tools, but no examples yet that use this wrapper result pattern.


r/javahelp • • May 08 '19

How to make program usable across multiple computers?

17 Upvotes

I want to eventually compile my program into a .jar file. And ideally, I would also make .exe/.app versions so that people (specifically my grandparents and less tech oriented friends lol) can try it without having java.

I'm working on both Ubuntu and Windows, and when I switch back and forth I need to repath my images. My program ultimately needs to work on a windows computer for my final project. But I am worried because my path applies only to my computers. Our teacher recommended that we compile our program into a .jar file so we dont have to worry about little complications beforehand.

Once my program is saved into a .jar file, will I need to worry about the paths still? Sorry, I'm super naive and have not done this before.


r/javahelp • • Mar 20 '19

Backend-development tutorials for JAVA where to find great updated tutorials 2019?

17 Upvotes

Because Java is still the best and most used programming language I would like to update my knowledge and learn more about the state of the art Java programming in 2019. Do you know of any updated tutorials on Java today? That is clear and well-formatted. Looking for good and simple tutorials on Java that covers everything for backend-development.


r/javahelp • • Nov 05 '18

Handling libraries in Java (confused python programmer)

17 Upvotes

I usually code in python where downloading libraries is conveniently handled using pip or anaconda. Installing libraries is not more complicated than running a single command in the terminal.

However just starting out with libraries in Java I find myself bewildered on how to download libraries in a convenient way... So far I've tried just downloading JAR-files from my browser manually but that isn't very efficient. I've tried looking into Maven but found it a bit confusing and I'm not even sure that's where I should be looking?

Any help is appreciated!


r/javahelp • • Jul 27 '18

I want to automate my tinder account using Java. How to do it?

17 Upvotes

I am in the process of learning Java and want to take on this project. There are many resources for python but I want to get experience with Java. I could not find many resources. Any advice?

end goal: Face recognition, automating messages (chat bot), storing phone numbers.


r/javahelp • • Feb 18 '17

Which Frameworks to use to build a REST backend in Java?

17 Upvotes

Hi,

I would like to build a REST backend in Java for a software that has multiple front ends (Angular 2, Cli and APIs in other languages). The backend doesn't need to be "web-scale" as it is only used in intranets.

From my research so far, I understand that there is:

  • The Spring framework (and related stuff like Spring Boot that you need in order to use it productively)

  • The Play framework (which seems to be newer, cooler and better in general, but is actually a Scala framework .. so as a Java user, I might not have the best experience)

These two solutions are pretty fat, as they are both full blown web frameworks with many features I don't need for my goal (templating engine or incremental rebuilds for example).

I wonder if it is not better to implement the REST-backend using:

Assembling everything myself allows me to use whatever build system I want to use (Maven instead of sbt (Play forces me to use sbt)), and I know how everything in my application is put together (one less framework to learn).

Who has done this before and provide me some guidance?

Thank you!


r/javahelp • • Dec 08 '15

Unsolved Game developer here: Anyone set up a java game in Steam app admin?

17 Upvotes

Hello Community,
I'm not sure if this is correct subreddit, hope I don't break any rules.. I'm working on a Java game which was Greenlit on Steam a few months ago and Im very close to releasing it (~2 weeks). I'm having troubles with setting up the launch configuration for my game in Steam and while I've set up the config for windows easily (since I use windows myself), I have problems with Mac and Linux.
On windows the Steam can runs the game properly if I define the exectuable as 'Game.jar' or a .bat file which runs 'java -jar Game.jar'. I've got testers which have Linux and Mac, but they cannot help me with providing a proper solution for their OS and I don't want to bug them for an hour each and ask "this works? and now? how about that?". So the question is, if anyone has experience with this, what kind of script could I upload to run the .jar for Mac and Linux, or how could I configure Steam to launch the jar properly? I googled a bit but I've learned that it's not that straightforward with running scripts on Mac and Linux as it is with Windows .bat.


r/javahelp • • Nov 30 '14

I start a job as a Java developer in 6 months! What advice do you wish you had known going into the field?

17 Upvotes

I'm a student about to graduate from college and after a successful internship got a job offer. I'm not entirely sure what I will be doing until they create the dev teams but I know I will for the most part be coding in Java. I'm just looking for any general advice I probably haven't heard in my classes and would like to hear what any experienced professionals suggest I learn to better prepare for the real world.

Edit: thanks a lot to everyone for the positive feedback, I will take all of your advice to heart! Luckily nothing suggested far has been totally unheard of to me, so I hope that means I'm off to a good start! :)


r/javahelp • • Mar 26 '14

What Java blogs do you read?

17 Upvotes

I am trying to find a good reading list of Java blogs. Are there certain ones you go to daily to check out?


r/javahelp • • Jun 19 '13

When would I use interfaces?

17 Upvotes

I've recently learned about interfaces, but when would I actually use them? Thanks!


r/javahelp • • Sep 18 '26

JVM Object immutability

16 Upvotes

I'm trying to better understand what immutability actually means from the JVM/JIT point of view,.

We often say that immutable objects are easier for the JVM to optimize, but I'm interested in what HotSpot can actually detect, prove, and exploit at runtime.

A few questions:

  • How does the JVM determine that a field, value, or object is effectively immutable or stable?

  • What optimizations does HotSpot actually enable when it has this information?

  • Conversely, what optimizations become impossible or harder when an object remains mutable?

I looked through some HotSpot code and didn't find much explicit handling of immutable objects for constant folding, apart from specific cases such as trusted/final fields some whitelisted JDK classes, and records.

I'm also curious about the practical trade-off:

How do you balance a low-allocation design based on reusable mutable objects, which reduces GC pressure, against a more immutable design, which may give the JIT more optimization opportunities but can increase allocation and GC pressure when you have a use case of mutable object ?


r/javahelp • • Apr 06 '24

I’ve being a backend developer for 8 years and I feel stuck

16 Upvotes

Hi guys,

From a few weeks ago I’m on bench at the company I work for.

I’ve been working mostly as backend developer for the last 8 years in Java/Spring.

The company has been trying to get a new client to work for me. To be assigned and be billable.

Meanwhile I have the opportunity to improve my skills, however I had never have a mentor or someone to ask for a piece of advice.

I have diagnosed me and I think I have these points to improve:

  • Cloud stuff, I’m about to start a guided and full hands on course for AWS certifications

  • Design patters, as Java developer I have applied so many of them but I often can recall when I’m being interviewed

  • How Spring framework works inside

  • Docker and Kubernetes stuff

  • Java advanced functional programming features and maybe some Kotlin, because in some job position they asked me to have exposure to Ktor

  • DSA, in some interviews they ask for a live coding question and have requested me to solve a leetcode medium level challenge

  • English C1 level, I’m not native speaker and I’ve working with my B1 level

  • Functional programming, I think that new approach will expand my mind and push me to think outside of the box (F#, Scala)

  • I’ve thought to make a horizontal move to devops engineering.

  • IaC, in a interview they asked me to know some terraform stuff

  • Data engineering, In some interviews they asked me to know some ETL stuff with Python

  • Learn another stack I like as C#

  • Be full stack and learn JS/TS with Angular

Despite that I’m in the paradox of choice, I don’t get what I really should pick and I feel as a imposter.

Any advice for that ?


r/javahelp • • Nov 02 '22

What JAVA framework should I learn in 2022?

16 Upvotes

Just got completed with core JAVA and I don't know where to go from here. Can someone tell me about the JAVA frameworks to learn in 2022?


r/javahelp • • Aug 25 '22

If my Java app does not respond for some very few seconds(because it has to wait for internet requests), a popup is shown and it says that my app does not respond and also asks if I want to kill it... is there a way to "increase" this timeout to a little bit more? It's a little bit ugly this way.

16 Upvotes

Is there a way to do that?


r/javahelp • • Apr 08 '22

GitHub examples of java spring boot applications that follow best practices

16 Upvotes

Where can I find some GitHub examples of java spring boot applications that follow best practices?

I found this, but there are no examples of response dtos, for example

https://github.com/ehabqadah/spring-boot-microservices-best-practices

I bet there's a community somewhere where they share such projects publicly but couldn't find it yet, I'd appreciate if you know such examples, it would really help me refresh my memory on best practices, syntax, etc.

I'm looking for similar project as linked above, microservices architecture with Controllers, Services, Repositories, Dtos, etc.


r/javahelp • • Jul 24 '21

Unsolved [Concurrency] What will you do if multiple users access your application at the same time?

16 Upvotes

I'm an experienced Software Engineer but very weak in concurrency because of no prior experience in that. I've been interviewing with several companies in which I was asked similar kind of questions as given below:

  1. If you are designing a fantasy sports application in which there's a contest which can handle only 100 users. If 99 users are already registered for the contest and multiple users hit the PARTICIPATE button at the same time to become the 100th user, then how will you handle this in your application?

  2. If you are designing a chess game, where multiple users are selecting the users of same level of competence to play with them. Then suppose at same time, users A and B choose the user C (to play with) at the same time, then how will you handle this?

I usually answer this by saying that I'll use synchronized block in Java or on Database side, I'll use Locking concept. But I'm not sure of either of them. So, can anyone tell here how do you answer such questions? Should one answer this in terms of Java Multithreading or DBMS or both? Please can anyone also tell me any resources to understand the theory to answer such type of questions or any website or YouTube channel where solutions are given to these kind of questions?


r/javahelp • • Jul 15 '21

Homework What are some characteristics in Java which wouldn't be possible without Generics?

16 Upvotes

In an interview last week, I was asked about the definition and use cases of Generics. But when I got this question (as mentioned in title), I was confused and stuck. The interviewer was interested to know something which wouldn't be possible in Java without Generics. He said that the work was also being done successfully when there were no Generics. So, can anyone here tell me the answer for this?


r/javahelp • • May 13 '21

Unsolved How to get information from the screen

16 Upvotes

Hey everyone! So I was messing around with java and I was wondering how you would get java to scan the computer screen for a specific color. Would you use a imported util or do you have to download something? Thanks!