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

0
votes
5answers
340 views

Liskov Substitution and SRP Principle violation - how best to structure this scenario?

While learning SRP and LSP, I'm trying to improve the design of my code to comply best with both of these principles. I have an employee class that has a calculatePay method on it. Firstly, I believe ...
-2
votes
1answer
47 views

Rename PDF extracted Pages File from a Single Booklet PDF in correct sequence [closed]

I have huge PDF files which are in booklet format. example, Assume a booklet pdf file has 24 pages which each page contains 2 pages which is in two sides - left side and right side. The first page ...
2
votes
1answer
200 views

What is the advantage of using Direct Web Remoting over a REST web services design? [on hold]

I have an enterprise Java web application deployed in tomcat. I am looking for ways to integrate a HTML & JS UI with the mid tier java code. So far, looking around I have found that there are two ...
0
votes
1answer
110 views

Simple unicode application?

I want to create simple language learning applications to help friends in learning languages. A simple Java console application would do the trick, but the Windows console does not seem to handle ...
3
votes
1answer
466 views

Hadoop and Object Reuse, Why?

In Hadoop, objects passed to reducers are reused. This is extremely surprising and hard to track down if you're not expecting it. Furthermore, the original tracker for this "feature" doesn't offer any ...
6
votes
2answers
436 views

Which is a better pattern (coding style) for validating arguments - hurdle (barrier) or fence? [duplicate]

I don't know if there are any accepted names for these patterns (or anti-patterns), but I like to call them what I call them here. Actually, that would be Question 1: What are accepted names for these ...
0
votes
1answer
91 views

Making a configurable Java formatter? [closed]

AFAIK there's just java.util.Formatter and java.text.Format and AFAIK none of them is extensible. I mean not subclassing, but the possibility to specify how to handle objects by class, e.g., saying ...
1
vote
1answer
226 views

Refactoring Tomcat webapp deployments

Background We have several webapps running on Tomcat 7.0.x (on Linux). For historical reasons, we have populated the "Common" lib (i.e. $CATALINA_HOME/lib) with many application jars. These jars ...
0
votes
0answers
4 views

Problem with opening JFrames from LWJGL [migrated]

I'm making a program that uses LWJGL to render a Display window, and it also listens for keyboard input to prompt it to open a swing window. The problem is, upon the first keyboard prompt, it opens ...
4
votes
2answers
1k views

Visitor stability vs instanceof flexibility

I am working on a GUI application which generates a configuration file. I have a class hierarchy for the configuration model and I use an object tree of that hierarchy in several different contexts. ...
0
votes
0answers
12 views

Java for loop: why can't I declare two variables in the for loop 'header'? [migrated]

I always wondered, why doesn't this compile? for(int i=0, int q=0; i<a.length; i++){ ... } Why doesn't Java allow me to declare more than one variable in the for loop 'header'? Is there a ...
1
vote
0answers
71 views

DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. Few points you might find helpful to answer to this question: The server The server is ...
1
vote
3answers
120 views

Null checking whilst navigating object hierarchies

I had to implement some code which traversed a small object hierarchy to fetch a value and display it in a TextView object (this is Android / Java). I had to do this 6 times to populate 6 TextViews ...
-3
votes
1answer
73 views

How valid is the statement “write once, debug everywhere” by some Java users? [duplicate]

How valid is the statement "write once, debug everywhere" by some Java users? If it is true, what is the effect to us?
-2
votes
0answers
13 views

Java GUI with JFrames [migrated]

Today I started learning Java GUI and tried to create a simple window on my Ubuntu. I am using jre7 for now. I wrote code exactly from tutorial because from experience there are stuff that doesn't ...
2
votes
2answers
106 views

Recreating files from shell script or java?

I have java application which takes a file, which is created by a process running on terminal. I start the process using a small shell script. Then run the Java application and it reads the file ...
-2
votes
0answers
32 views

How to connect a Django app with a Java Web app using JMS

I'm dealing with my DB systems course project, it's a stock exchange simulation app using Oracle 10g, the deal is that the support is for Java, but i'm going to do this in Python. The last iteration ...
2
votes
1answer
194 views

Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one ...
2
votes
1answer
156 views

Benefits of Java ByteArrayInputStream vs byte array?

I have a scenario where my Java process will be receiving a stream of binary data: public class DataHandler { public void handleData(DATA data) { // TODO: Do something with data } } ...
0
votes
0answers
17 views

Apache Wicket, updating data without using a form, is it safe?

I have a ListUser.java class with a datatable, displaying UserData information, displays 4 columns, the last column is an AbstractColumn that has on it's populateItm method has added a inner class ...
1
vote
2answers
278 views

Where should I put bindings for dependency injection?

I'm new to dependency injection and though I've really liked it so far, I'm not sure where bindings should go. I'm using Guice in Java, so some of what I say might be specific to just Guice. As I see ...
0
votes
2answers
66 views

Logging Exception in multi-tier application

I'm building a multi-tier enterprise application using Spring. I have different layers: Controller, Business and Provider. Within the application I've built a custom error handling mini-framework that ...
2
votes
2answers
76 views

Static Test-Data in Helper Class: Getter vs Public Constant

Currently I am in process of writing large batches of Unit-Tests in the Project I am working on. Additionally we recently Introduced GUI-Testing. This project is a relatively simple webapp, on basis ...
11
votes
4answers
4k views

Why were default and static methods added to interfaces in Java 8 when we already had abstract classes?

In Java 8, interfaces can contain implemented methods, static methods, and the so-called "default" methods (which the implementing classes do not need to override). In my (probably naive) view, there ...
1
vote
0answers
89 views

Large Scale Application Development in Android

Since, I am fairly new to large scale app development in Android and Java, I though I would ask for your advice guys. My team was faced with developing a prototype of a fairly complex medical ...
0
votes
1answer
215 views

MVC: How to Implement Linked Views?

I'm developing a java application to visualize time series. I need (at least) three linked views, meaning that interaction with one of them updates the others. The views are: A list represents the ...
0
votes
1answer
256 views

Email Content creation | Proper design

Working on an E commerce application where we need to send so many email to customer like Registration email Forget Password Order placed There are many other emails that can be sent, I already ...
0
votes
9answers
3k views

Line break before/after operator [closed]

While Sun's Java code convention suggests to put line break before the operator many other guidelines disagree with it. I do not see any obvious pros and cons, so are there advantages of using one of ...
0
votes
1answer
87 views

How to manage data flow between UI components?

I have been trying to use classes that implement ActionListener to respond to user input. I'm consistently noticing that for an action listener to communicate the event to other objects, it has to ...
0
votes
1answer
62 views

A 'task' system which has an ending, to get ready for next task

I want to make a system, so that there are certain tasks. For example, let's talk about a game. I want to make it so there are 100+ tasks doing different things, but when the player's magic level is ...
2
votes
2answers
179 views

Parameterized Java Types (Generics)

Consider this "legacy" code: public interface IPersistentCollection { IPersistentCollection cons(Object o); } Genericized in Java, it could become something like this: public interface ...
-2
votes
0answers
13 views

UnmarshalException while consuming a web service [migrated]

I have a web service based on a number of entity classes. one of them is shows below @Entity @Table(name = "users") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Users.findAll", query = "SELECT ...
1
vote
2answers
134 views

How to let the outside world decorate my private field?

Imagine a simple Controller (as in process control) interface. I have some concrete classes, say PIDController, that implement it. I also have some decorator classes that extend these classes ...
3
votes
2answers
294 views

Dalvik + Java licensing question

This is a licensing question about the Dalvik and J2SE core libraries. In particular the license governing java.util.concurrent.SynchronousQueue. The license header of the class in the JDK source ...
1
vote
1answer
43 views

Using Mockito.reset

I've just read a lot of arguments against using Mockito.reset and can't make much sense of it. Put differently, I agree in general, but there's always a case which looks like using reset is useful or ...
0
votes
1answer
52 views

How to get Datasource JNDI access to work with WebLogic reliably (no NameNotFoundException)?

in a WebLogic web application (bundled and deployed as a Jar) I sometimes get a NameNotFoundException when I try to fetch a datasource using JNDI lookup. The datasource is not shown in the JNDI tree ...
3
votes
5answers
450 views

Proper OO design for State and Command

I'm working (a bit) on a (turn-based strategy) game. There are two classes relevant for the question: State: This is an immutable class, which exposes all its fields (either via getters or another ...
0
votes
2answers
71 views

C++ Data Server and J2ME client communication [closed]

I am working on a robot that has some AI built in. However, the mandated robot controller does not have the power to do the work onboard. This means that I need to use a co-processor. I am writing ...
4
votes
1answer
173 views

Approaches that cater for poor connectivity

First off some background info My company has a software as a service model where people log onto our servers and do work. In order to support that application we have a utility application that ...
1
vote
1answer
88 views

Why is Throwable initCause designed to be called only once?

I find it really odd that the initCause method of Java's Throwable class can only be called once, or even not at all (if the constructor accepting a Throwable was used). This makes exception chaining ...
12
votes
6answers
1k views

Using nested public classes to organize constants

I'm working on an application with many constants. At the last code review it came up that the constants are too scattered and should all be organized into a single "master" constants file. The ...
1
vote
1answer
45 views

How to allow multiple plugins to provide data for multiple aggregation processes?

I'm working on a Java project in which we want to have data collection plugins that collect data to be processed by one or more data aggregation modules. The plugins will all written in-house. Say for ...
0
votes
3answers
122 views

How should be the approach to start thinking about multi thread programming [closed]

I am an experienced java developer.Of now I have started learning multithreading in java.I am able to grasp most of the concepts but still I am unable to visualize applications running on threads.I ...
0
votes
1answer
173 views

Dynamic query in Mysql

I'm doing a J2EE web application with Struts2, Mybatis and a MySQL database, so what I want to allow to the user is to be free to choose different parameters to perform a select to a table in the ...
0
votes
1answer
546 views

Java: How to manage UDP client-server state

I am trying to write a Java application that works similar to MapReduce. There is a server and several workers. Workers may come and go as they please and the membership to the group has a soft-state. ...
2
votes
3answers
211 views

Decoupling software components via naming convention

I'm currently evaluating alternatives to refactor a drivermanagement. In my multitier architecture I have Baseclass DAL.Device //my entity Interfaces BL.IDriver //handles the dataprocessing ...
1
vote
2answers
213 views

Java: how can I make the return type, of an inherited method in a subclass, the same as the subclass?

I am rather inexperience in Java, and I'm having a problem in forming a subclass of a class I have created. The class I have made, called Vector2D, contains methods, such as add(Vector2D addend), that ...
0
votes
2answers
174 views

DTO - service layer - statelessness best practices interfering with each other

I am designing a REST API coupled with a service layer that takes DTOs as input and produces them as output. This works fine for most service calls where the DTO is used to access an underlying ...
1
vote
1answer
352 views

JSP Include: one large bean or bean for each include

I want to refactor a webapp that consists of very distorted JSPs and servlets. Because we can't switch to a web framework easily we have to keep JSPs and Servlets, and now we are in doubt how to ...
0
votes
1answer
106 views

Ajax call or js to update a cart price

I am building a cart in Java and would like to give users the ability to update the quantity and see the new price instantly. I am using BigDecimal on the back-end for complete accuracy, but the ajax ...