Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems. Java is currently owned by Oracle, which purchased Sun in 2010.

learn more… | top users | synonyms

1
vote
1answer
54 views

Coding guidlines for Controller and Dao?

My Controller code: ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ObjectReader objectReader = objectMapper.reader(...
0
votes
1answer
42 views

Removing constraints of Java array

Java arrays only allow subscripts to range between 0 and N-1 for an array of size N. The class below aims to remove that constraint by allowing the class user to specify the valid subscripts ...
1
vote
2answers
100 views

Adding properties to exceptions

Is it wrong to add fields to exceptions? I have a problem that happens and I'm thinking of adding considerable information to an exception, but it sounds weird: an exception with getters. What you ...
0
votes
0answers
24 views

Providing an API for Cancel(QueryID) i.e. Cancelling a long running query through JDBC in RESTful service

We went through few blogs on internet, which suggested to use Statement.close() method. Our scenario : We have developed RESTful service. We execute an SQL query through JDBC framework behind an API ...
6
votes
3answers
581 views

Is it better to expose or hide dependency in OOP?

Let's say I have an object A, which is too big(having too many methods and variables). So, I break it down to smaller objects. After that, I have Object A, B, and C. Obviously, Object A is from Class ...
2
votes
1answer
47 views

Memory allocation while calling a sequence of functions in Java

A method getReminder takes two integers and returns r = (a^5)%m. This method relies in two BigInteger numbers BigInteger.valueOf(a).pow(5) and BigInteger.valueOf(m), but BigInteger was never declared....
2
votes
2answers
185 views

Why does the development team of IntelliJ IDEA‎ store its dependencies as jars (e.g. JUnit) inside their cvs?

The very popular IntelliJ IDEA‎ has currently saved a lot of dependencies as actual jar files in their git repository e.g.JUnit, which I don't understand. Build tools like Maven provide excellent ...
-1
votes
2answers
160 views

Is main() function better on top of all other functions? [closed]

My college professor told me that main functions should be defined on top of other function definitions. We should use a forward declaration in order to accomplish this (we use C at that time). So yes,...
1
vote
2answers
155 views

Structure of RESTful Service with Java Spring for Beginner

I am relatively new in terms of Java web development skills. I have a project that I think would make a good candidate for a RESTful service from what little I understand about APIs. I'm trying to get ...
0
votes
2answers
120 views

Where/how to store program data?

This may be more of a software design question - but I've been working on my first "real, non-academic" Java project and have recently learned about good code practices (such as breaking down methods ...
0
votes
0answers
38 views

coming from java to nodejs whats the convention for error handling logging? e.message or e.stack?

I come from java, when I got an expected error I printed stack traces. I'm coming now to work on nodejs (never really worked on javascript). and in the nodejs project which I need to maintain (...
-3
votes
2answers
41 views

ArrayList Dynamic remove and add for socker client [closed]

I have one ArrayList in Java and a save the socket and one unique id. When someone client is add in the ArrayList, the unique id i have is NOT the same with position in ArrayList. When someone ...
1
vote
1answer
52 views

Distributing an application in 2 or more servers

This is probably a common question and I've been reading a lot about this, but I can't look into a solution. Let's say I have an enterprise application in one glassfish server located in New York. ...
4
votes
2answers
177 views

Distinguish different type of Comments

I would like to provide design decisions in the comments as well. I want design decision comments to be distinguishable from function contract comments, on cursory examination of source code. How to ...
0
votes
1answer
170 views

Business logic - Server side vs client side [duplicate]

In my current project, I have a screen which pulls data from several webservices, pulls data from database via backend API and checks that all resources have the same data or not. The other ...
2
votes
1answer
164 views

When to lock an object in a game

I'm writing a game in Java where each game object has a number of properties, but these can all be changed in one of two ways: Every second, a tick runs which may automatically cause a change. Users ...
1
vote
1answer
67 views

Software architecture for uploading dynamically created websites

I have a question that is crucial for my end of year project. Background My web application allows users to build other webapps based on drag&drop (within the domain of the webapp). These ...
0
votes
1answer
118 views

How to name this class? Is it a pattern?

I need to create a class which will have the following structure: public class MyClass { ArrayList<File> myList = new ArrayList<>(); public void addFile(File f) { myList....
1
vote
1answer
50 views

jersey post with a huge payload

I have a requirement to write a POST endpoint where the payload is huge(not normal). In the order 10s of Megabytes. And this endpoint will be accessed by a lot of clients (in the order of 1000s) ...
2
votes
1answer
54 views

Maven Build Lifecycle: validate

In the build lifecycle in maven, I encountered the validate phase described as validate the project is correct and all necessary information is available to complete a build 1. what are the check ...
1
vote
1answer
135 views

What are the significant memory management models aside from Java (GC) and C++ (manual approach)? [closed]

There are at least two distinct memory management models: Java (we do it for you) C++ (it is your responsibility) I have two questions: (1) Is GC language specific or compiler specific? (2) Do ...
1
vote
1answer
54 views

What is the recommended way to handle exception in Spring MVC

I have a Spring application, where we make few service calls to fetch data. There is a Data Layer in between the Controller and the Service layers. Controller (Request-Mapping) -> Data Layer -> ...
5
votes
3answers
612 views

Is it a good practice to use suppress warnings in your code?

I use @SuppressWarnings("unchecked") and @SuppressWarnings("null") mostly above methods to let the code compile without any warnings but I have my doubts. Found this Stackoverflow question. Jon Skeet ...
-1
votes
1answer
100 views

How to design property files

I always wonder what is the best way to design your property files. I have few questions that I didn't find an answer to them Do we place all our labels / error messages in one file? Do we split the ...
0
votes
2answers
66 views

Many instances of application, or single application with many threads?

I'm developing a Java application that will handle huge XML files (up to 300mb each and hundreds of thousands of lines). They are grouped usually with 20 to 40 similar XML files that also need ...
0
votes
0answers
26 views

The best implementation for fromJson factory method and json-mappings with inheritance?

I have BaseComponent (with field "type") and it's subclasses TextComponent, ListComponent, etc. Some of them has same fields. I want to create them and init their fields from json. Some of possible ...
0
votes
1answer
40 views

How to deal with automatic binding exceptions with Jersey?

It's really nice to have automatic binding with Jersey-Jackson (well, I believe it's actually MOXy the one who manages the bindings), so object serialization and deserialization is done under the hood....
2
votes
2answers
156 views

Should I return a 204 or a 404 response when a resource is not found?

I am developing a simple RESTful service for tournaments and schedules. When a tournament is created through a POST request containing a JSON body, the tournament is inserted in a BiMap, declared as ...
9
votes
3answers
266 views

Why does java.time have methods for creating objects instead of just constructors?

In the new java.time package the core classes are using the factory method of instead of a public constructor. Even though I like the cosmetics of the of method I can't see a good reason to not use a ...
0
votes
1answer
95 views

Divide java web app into smaller web app

I've a web application that consists of 3 main technologies: JSF, jax-rs and websocket. All three are coupled together with the help of CDI injection and JPA. That means that when a user login, he ...
2
votes
2answers
113 views

Data structure to hold Excel column names with their values

I am learning how to read Excel workbooks in Java and want to know what a good Data Structure will be for holding Column names with the values under them. Example: I want to be able to call a ...
0
votes
1answer
126 views

Using database connection on multiple threads

let's say I have a database connection in the class Database which offers the following public methods public synchronized void open() {} public synchronized void close() {} public synchronized void ...
1
vote
2answers
180 views

What is the role of “throws exeption” in method definition in Java?

Some methods are deciared this way: public int myMethod() throws Exception { (return an int or throw Exception if method fails). However, stub methods in NetBeans look like public class JavaApp { ...
1
vote
1answer
145 views

what is this kind of object creation?

final CyclicBarrier cb = new CyclicBarrier(value,new Runnable(){ public void run(){ ...statements } }); suppose you have a cyclic barrier in which one of the the arguments is the direct ...
0
votes
0answers
104 views

Best way to spawn enemies with independent (x, y) positions?

I am trying to spawn simple GRect enemies on different (x, y) positions, although, the problem is that I need the enemies to operate on different movement speeds. while(true) { enemy[i]....
0
votes
0answers
26 views

Java Drag and Drop, registering certain parts of the object

Say I have an application where the use creates an electrical circuit visually, how would I go about registering when two ends meet? I've seen this thread http://stackoverflow.com/questions/8562743/...
-1
votes
1answer
31 views

Language cross platform that allows different socks connection per thread

Hello i'm developing an app that needs to do many requests with different socks connections. I was doing it in C# but i'm not sure how well it will work on a linux server even with .net core . Java ...
0
votes
0answers
49 views

Making DAO's independent on each other

I have these two classes (Getter/Setter/Constructor omitted): public class Company { private String name; private String adress; private List<Employee> employees; private Uuid ...
2
votes
1answer
86 views

Collect and prcess data from multiple threads in Java

There is a Java program that reads a list of orders and for each order starts a thread that receives data from SQL and prints the list of items in a given order to an order_name.html. I want to write ...
1
vote
1answer
61 views

UML: do I use aggregation or composition in this case?

I would like to draw a UML sketch to communicate part of a software but the type of relationship between classes does not seem very clear cut to me. Let's say I want to periodically fetch the recent ...
2
votes
1answer
88 views

Should domain models instantiate other domain models?

I'm reading Domain-Driven Design at the moment and I'm trying to understand what should go in services and what should go in domain models. Say there is an application where you can reserve seats for ...
0
votes
3answers
438 views

Why do we call Java open source, when development or contributions are not decentralized

Open source software should be developed by different contributors in decentralized fashion. I understand that Open JDK is reference implementation of Java which is open source and it allows ...
0
votes
0answers
22 views

Are there special considerations to take for the database when using Hibernate's @Version?

We've encountered a bug which is solved by adding a @Version-ed field. However, I'd like to know if I need to add something special in the database (Oracle 11g), like adding some index on the new ...
0
votes
1answer
211 views

Recently moved from java to javascript on nodejs, how to maintain code? Help!

I recently moved from java to javascript on nodejs. I was very excited, opened up my intellji IDE for an existing nodejs project only to find I cannot know what the parameters I see functions ...
0
votes
0answers
14 views

JPA: Property/encapsulated objects instead of fields

I'm moving to JPA (JavaEE, Eclipselink) from a very large C# project. The classes were not using simple fields but Property objects. Example: //C# public class State : DataObject<State> //base ...
8
votes
2answers
296 views

What is an output argument, as refered to in Martin's Clean Code?

On page 45 of Robert C. Martin's Clean Code: A Handbook of Agile Software Craftsmanship, Martin writes that output arguments should be avoided. I'm having trouble understanding the meaning of "output ...
4
votes
7answers
639 views

C++ delete vs Java GC

Java garbage collection takes care of dead objects on the heap, but freezes the world sometimes. In C++ I have to call delete to dispose a created object at the end of it's life cycle. This delete ...
4
votes
2answers
180 views

The order of values in ? : expression

Which construction is more readable: someVariable == null ? SOME_VALUE : someVariable; // avoids negation someVariable != null ? someVariable : SOME_VALUE; // normal situation first I have to ...
0
votes
0answers
13 views

JVM run-configuration launcher for production?

Does anyone know if there is such a thing as a run-configuration launcher for the JVM for "production"? Where you can set environment variables and arguments, just like in an IDE ?
0
votes
2answers
81 views

Using Super.someMethod for added clarity?

Is Super.someMethod() a good practice to add clarity to the code by explicitly stating that someMethod is not a method included in the current class but in the parent class? For instance, would this ...