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
76 views

Manual reload of Java classes static block

I have a static block which fetches data from database. This data is then being used by instance method. Since static block will be loaded once I fear that the data won't change in its lifetime. How ...
0
votes
0answers
55 views

Using counter or constant for parameter position

Suppose that I have the following Java code: int i = 0; PreparedStatement statement = con.prepareStatement("SELECT * FROM table " + "WHERE field1 = ?, field2 = ?, field3 = ?..."); ...
3
votes
1answer
113 views

Is it good practice to access database in mapping between object

Situation I receive message from a 3rd party, and these messages are use to create or update database information. Message and data to be updated can be de-serialize in object form, but are not ...
5
votes
2answers
170 views

How do I use checked exceptions without violating the Law of Demeter?

Given a language that enforces checked exceptions (let us assume Java), how do we design an API that can throw exceptions without violating the Law of Demeter? To put this question in the proper ...
5
votes
1answer
436 views

Are we abusing static methods?

A couple of months ago I started working in a new project, and when going through the code it stroke me the amount of static methods used. Not only utility methods as ...
0
votes
3answers
81 views

How to represent an object with actions that can only be used in a specific situation?

Let's say I'm designing an RPG type game, and this game has a turn-based combat system. There are some things that the player character/non-player characters can do inside and outside of combat. For ...
-1
votes
1answer
57 views

How to display a non-interactive message on a JFrame? [closed]

I'm writing this code here: import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.swing.UIManager; public class FirstJavaClass { public static void ...
0
votes
0answers
41 views

Customizing xmlAdaptor in JAXB

I have hashtable which contains columnName and column value. My hashtable contains key,value pair as like columnName = columnValue columnName = columnValue columnName = columnValue columnName = ...
3
votes
1answer
174 views

What are modern develop-deploy-test techniques for non-interpreted languages?

I have strong web-developer background, where in order to show client a demo I've uploaded a solution to demo environment and sent over a link. If case client asked to make changes, I did them in ...
1
vote
1answer
153 views

Is it true that JVM language is difficult to integrate with C than other language? [closed]

I have seen many libraries provide high level API in the language like python or lua. For example: The linear algebra library "Trilinos" provides a python API. The deep learning framework "torch" ...
-3
votes
1answer
98 views

Which is best practice to save uploaded images in a database or in a folder [duplicate]

I am developing a project in jsp and servlet and I am using mysql database, I want to upload many images from my application but I am confused where I save uploaded images in the database or in a ...
3
votes
2answers
108 views

Is an attempt to create a duplicate resource, e.g. a user, worthy of throwing an Exception?

Say I have an REST API for creating users in an application. The request goes to a controller, which marshals the request data into a domain object, and passes it to a service to create a user. Now, ...
1
vote
0answers
53 views

Creating duplicate instances of objects for timeline functionality

I am working on a Spring-MVC based project, in which I would like to add Timeline functionality. The most important object in our project is the Note, there are objects associated with it like ...
1
vote
0answers
116 views

OOP - Modeling a Chat Design Review [closed]

Seeking thoughts on the following design. I know the design could be lot simpler if use Sockets. But I wanted to think of a design with pure POJO classes. User string id; string displayname; ...
1
vote
1answer
72 views

Determine what to draw based on neighbour tiles?

I have a tilemap and I want to add walls to it. I painted 16 images, one for each possible combination. For example: A lone wall tile would get a image that has walls around. A corner would get ...
2
votes
1answer
113 views

Using Spring in Java Project

I've got a question about a correct usage of Spring. I know that some people use the DI "aggressively" so that they always use spring and completely eliminate the usage of word "new" in the ...
2
votes
2answers
408 views

Why packages and modules are separate concepts in Java 9?

Java 9 will have modules in addition to packages. Usually languages have one or the other. And most programmers perceive two terms as synonyms. Modules are built on top of packages, treating them as ...
2
votes
1answer
110 views

How to handle shutdown/startup of a Java application that relies on real time events?

I have this Java project called Server. Server is essentially a single-threaded application that listens to events from external applications. These events are crucial and missing one is a huge deal. ...
1
vote
1answer
226 views

Is it OK to do IO inside java 8 streams?

Example to question in title: List<UUID> ids = dao1.getContactsOfUser(userId); List<String> contact_names = ids.stream .map(uid -> dao2.getContactByUid(uid)) //is it ok? ...
1
vote
1answer
185 views

Log4j logger per class vs logger per application

I am stuck at understanding a concept related to Logger creation, especially in the context of Java EE. In my experience, I nearly always used one logger per application, with few cases when I needed ...
3
votes
1answer
93 views

Is it unreasonable to implement a small domain specific scripting language?

At my new job, they are currently spending scores of labor hours that we don't have to do manual QA testing after every build. Nothing is automated at all. (We can only afford three developers, and ...
1
vote
2answers
115 views

How to sync the data from the same user across multiple devices

I'm working on a small fitness app in which the user (whom is authenticated with the a server) could create their own workout plan which will be synced with a server. The problem with this is that ...
1
vote
1answer
82 views

Recieving errors without engaging in excessive communication when using sockets

I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of ...
0
votes
1answer
150 views

Should I use import java.util.* for bringing in just one class?

when we import the Scanner class to a program which is the best and most suitable method from these two? import java.util.* import java.util.Scanner I'm a totally newbie to the programming and I ...
5
votes
2answers
151 views

Floating point calculation being too exact

In Java, I've run this method: private static void floatAddition() { float a = 0.1F, b = 0.2F, c = a+b; System.out.println(a + " + " + b + " = " + c); } and the result is 0.3 for ...
5
votes
7answers
403 views

Is it appropriate to not follow the O/C principle if you have unit test coverage?

I find it more convenient to 'modify'existing classes rather than extending them. Thus, I violate the open closed principle of 'not modifying the compiled and tested source code, instead extending the ...
3
votes
2answers
126 views

How do you handle sequentiallity in API's?

Consider a use case of the form: The system shows a list of potential filters (by name, by creation time...). User chooses a filter and supplies necessary parameters. System shows a list of ...
0
votes
0answers
57 views

Concepting a Server - Handling Clients/Connections

I am writing the Server-Side of an Application, just for practicing my Java programming skills. I have made an attempt to program it, but I am not satisfied with my solution and I think it is because ...
0
votes
1answer
133 views

How to save tuplas values, to later search on it

Scenario I have some values of the type : (Name - Email) From this couples of data, I have to set a ArrayList of "Name" values,something like: |Name1|Name2| --- |NameN| to set a Spinner. (Ordered ...
3
votes
4answers
245 views

Exception treatment with/without recursion

I've entered in an argument with a fellow colleague about a piece of code. While he thinks that it is ok, I don't. But I don't have any more arguments than that calling the same method (recursion) in ...
1
vote
0answers
61 views

is Command appropriate software pattern for this?

I have following task: I need to send several instructions after each other to the hardware. Next instruction is never sent before either answer to previous instruction comes (valid answer or error) ...
0
votes
0answers
15 views

Conceptually, how should a unidirectional multivalued relationship be implemented?

Ok, I'm trying not to upset the programmers list, but not so successful so far. My apologies. I'm trying to understand, conceptually and based on experience, which is the correct way for a JPA ...
1
vote
2answers
198 views

Is it viable to copy contents of a database into a program's memory, if multiple queries take time?

The task: I have a database with 4 tables with 200 rows, 800 rows, 50 rows and 30 rows respectively. Just to simplify it, let's assume the tables are these sets: A = [Ar1, Ar2, Ar3], B = [Br1, Br2], C ...
-2
votes
2answers
131 views

Java Integer - Immutable [closed]

I cannot understand the definition. Here's some code: Integer iW; for (iW = 1; iW < 4; iW++) System.out.println(iW); int i = iW; iW += 6; System.out.println(String.format("iW = %d, i = %d", iW ...
3
votes
0answers
71 views

Determine equality of a DAG

Given a fairly traditional node class (below), whats the best way to implement equality on a given graph? If our node looks like this public abstract class Node{ private final Set<Node> ...
3
votes
2answers
176 views

Generating Java Classes with Compile-time Value Parameters

Consider a situation where a class implements the same basic behavior, methods, et cetera, but multiple different versions of that class could exist for different uses. In my particular case, I have a ...
0
votes
1answer
39 views

Spring Consuming Internal REST WS for MVC

Sorry in advance if this is a little confusing, it's difficult how to phrase this. I am currently using Spring MVC with some RESTful services mixed in for some AJAX client side logic. I am looking ...
55
votes
4answers
6k views

Is functional programming faster in multithreading because I write things differently or because things are compiled differently?

I'm diving into the world of functional programming and I keep reading everywhere that functional languages are better for multithreading/multicore programs. I understand how functional languages do a ...
3
votes
2answers
285 views

Is it better to have one web app or multiple web apps

I am going to develop a server application to provide the functionality of a book keeping software in tomcat server. I can think of two ways to achieve this. Creating a single web application - ...
6
votes
3answers
192 views

Doesn't returning a Collection as Unmodifiable / Immutable unnecessarily break method scope?

Let's say I create a Collection in an instance method. I do not assign that reference to any instance variables. Rather, I just return it to the invoker. Then, I exit. Now, the only thing with a ...
2
votes
0answers
71 views

Error handling in distributed system

This is the common sequence of two distributed components in our Java application: 1 A sends request to B 2 B starts some job J in parallel thread 3 B returns response to A 4 A accepts ...
1
vote
0answers
102 views

Change object state in different point in program

This is not about whether or not getters/setters are wrong. I understand its impact to encapsulation and that question has been raised here and SO several times already. I also do not want to just ...
0
votes
1answer
84 views

Data Structure for Form or Survey [closed]

I am planning an app which allows users to complete surveys/forms. I'm having trouble planning the data schema for the forms. I really want to have a data structure which can be mostly automatically ...
0
votes
0answers
52 views

Is Shiro's use of Auth Exceptions an example of control flow? [duplicate]

In Java/OOP-land, it is a well established anti-pattern to use exceptions for control flow. Apache Shiro is one of the standard Java security frameworks. When using Shiro, especially when ...
1
vote
2answers
230 views

How to reduce size of jar file?

I dont know how to reduce the size of jar file. When we normally code in Java Swing the jar file is created, is there any way to reduce the size of jar file? I can't remove the images and other stuff ...
2
votes
0answers
25 views

Approach for querying an arbitrary set of user submitted fields and values in Spring application? Like a shopping site sidebar search?

I am working on a Spring Boot and Angular application which has a requirement to search based on any number of the available filters being applied to a list. For example, a user searches on 'Title' ...
0
votes
0answers
130 views

use of minOccurs=“0” without nillable=“true” in SOAP

I have received an XSD from a 3rd party supplier generated from a Java based system; which is to be used to create a SOAP endpoint for us to receive data transfers. Their XSD does not make any use of ...
0
votes
0answers
34 views

Implementing logging interceptor next to BeanPostProcessors and BeanNameAutoProxyCreator

I want to implement simple mechanism based on annotation on method in different classes. The case is, that I have some beans created as a proxies with transaction interceptors like this: <bean ...
4
votes
1answer
123 views

Is it better not to .close() inside API method body when passed a Reader or InputStream?

There are plenty of similar questions that have been answered. Example here. However, they all have both the Reader and the InputStream within the same scope or method body, and so suggest to close ...
0
votes
0answers
39 views

WCF security with Java client

I'm about to develop a WCF service which is going to be called by an external Java client. I've developed a couple of services before but they were called internally, so security is now a concern. ...