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
1k views

is there a java library to create assisted wizard flow into your desktop application? [closed]

I am looking to create a step by step introduction/wizard guide to help users create a job on my application. For example, they will told what to click, and will be asked what actions they would like ...
2
votes
1answer
103 views

Is Singleton enough for a EMailUtil or there is any better implementation? [duplicate]

I am developing an application, where I have to send lots of emails for user account creations, validation, invites etc. I have implemented a static class EMailUtil which has different methods like ...
2
votes
1answer
88 views

Simple and Composite transactional services: Question about separation of concerns and transactions

I believe I know the answer to this but I'm looking for any holes or anything I may be missing. This is focused on Spring and Java but could really apply to any programming stack. Anyway, we have a ...
2
votes
4answers
215 views

Why is the hashCode method usage of HashSet not specified in the API?

I was trying to debug my code which uses a HashSet and searching through the SO, I found out that I needed to override the hashCode method as well. The strange part is, checking the related API, I did ...
-1
votes
0answers
46 views

Java - Can't call an Array from a different method [migrated]

I've been a long time lurker, and I've come across a part of my code I cannot figure out even with the help of stackexchange. I can't seem to call an Array from another method of mine. I have a bunch ...
2
votes
1answer
52 views

Creating/updating entity save strategy

Please note: although I'm talking about Java in this question, what I'm asking about here should really be language-agnostic. I am dabbling in OR/M for the first time, and have cooked up the ...
1
vote
2answers
90 views

Improve the speed of a Tomcat Server with MySQL

I'm developing an application with 3 sides, desktop (JavaFX), server (Tomcat) and Android. And a MySQL Database Server. The app receive mails and convert them into tasks. The tasks are sent to the ...
0
votes
0answers
33 views

Programmatically extending table/entity definition mappings through aspects in Spring and Hibernate

I would like to know if it is possible to use AOP to extend table/entity definitions so that I can add functionality across the board that requires persistence. Let me explain what I want to do with ...
2
votes
0answers
69 views

is there a way to tell JDBC I am about to execute a transaction? [migrated]

when setting AutoCommit to false; is this means that I have to commit after executing every sql command in my application. here is a scenario SQL1 doesn't need to be a transaction. SQL2 needs to ...
0
votes
1answer
162 views

Logic based on modified fields of a Hibernate entity

I have a Hibernate entity object MyObject with several attributes and a service MyObjectService containing business logic dealing with MyObject. I also have a view model dealing with user input/output ...
14
votes
8answers
3k views

Why does the Java collections APIs not have a last method? [closed]

This is for ordered collections e.g. java.util.List. Why did the language designers not include a last method? The only reasons I can think of are: ambiguity when the collection is empty (return ...
-2
votes
0answers
48 views

What is the best way to store user uploaded Java files? [duplicate]

I am working on a website where users can upload their own Java files, and we will later compile and execute them. I will address the risks of executing users' code separately, but what would be the ...
2
votes
2answers
127 views

Designing a system to archive databases with referential integrity

I have a very large Oracle database, with many many tables and millions of rows. I need to delete some of the rows end-to-end. By end-to-end, I mean, if I want to delete a row from a table then I must ...
0
votes
1answer
146 views

Spring web application deployment infrastructure

I'm interested in hearing out what's out there in terms of tips and tricks on deploying and maintaining a Java web application whilst keeping agile. I'm running solo on a startup project I'd like to ...
1
vote
1answer
122 views

Creating a calendar/planner program. Confused about OO logic?

I'd like to create a piece of software that has the functionality of a common written planner. To do this, it will have a Calendar. When planning the program, I became confused as to how I would ...
0
votes
1answer
92 views

Cleanest choice for symmetric operations

I have a need to do some processing from a format A to a format B and from B to A. The job in one direction is very similar to its counterpart. Both formats are represented with an interface Msg. In ...
1
vote
1answer
193 views

How to render graphical interface automatically (behind the scenes)

I am trying to write a program that shows images of a Java application's GUI automatically (ie, without someone building, running, and then taking screenshots of the interface). I know WindowBuilder ...
0
votes
2answers
264 views

Where is it specified that Java is call by value?

I know that Java is by default call-by-value but I am not sure where in the Java Language Specification this is addressed. Google searching only seems to find me unofficial sources but never points to ...
0
votes
3answers
167 views

Building a calculator using MVC

I've been programming in Java for about 6 months, and I thought a good and challenging test of my skills would be to build a GUI calculator. I have very recently heard about this MVC idea, and I ...
-1
votes
0answers
102 views

How do i wait for all threads in java code here? [migrated]

I would like to compare thread performance on solaris/linux/windows 64 bit JVM's, with the below code. I personally, prefer this style of coding for threading, because you have a method performing ...
0
votes
2answers
74 views

Managing multiple JDBC connection

I have an application that connects to databases based on a json string that contains connection information. The json is sent just when the application starts. How do you manage such connection ...
1
vote
2answers
373 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 ...
-1
votes
1answer
178 views

Whether Methods could be defined in Constructors in Java? [closed]

I am learning to program in Java and have run into a situation I don't understand. I have this code import java.io.*; class temp { temp() { Finish f=new Finish(); f.end(); } ...
-2
votes
0answers
146 views

Trying to create the simple 24 game in java, I have some code but I need to reverse it [duplicate]

I am trying to create the 24 game in java and I found some code that does what the game is supposed to do. This code give the user 4 numbers and the user then has to put them into an equation to equal ...
-3
votes
1answer
60 views

Why are there just a few implementations of a Java EE container? [closed]

I see at the JCP that work on Java EE 8 is allready in progress, as Java EE 7 was released almost 1,5 year ago. However, as far as I know there are only three implementations of the Java EE 7 ...
0
votes
0answers
7 views

What is first argument in 'JOptionPane.showConfirmDialog() here? [migrated]

Here is the below code snippet, where i would like to display the dialog using JOptionPane.showConfirmDialog() by setting its parent as resultsTablePanel: public class SearchResultsTablePanel extends ...
1
vote
1answer
94 views

Java App as Tomcat Service?

I currently have a basic j2ee website. Currently, a jsp frontend gets data from the backend (the java program, lets call it object "Score"). The backend gets this data from a web site. <% Main m ...
-4
votes
1answer
114 views

What is immutable by default in Java? [closed]

While trying to grasp copying/copy constructors, and noticed that some things seem to be immutable by default (Strings, and Integers), while everything else is mutable by default. That leaves me ...
0
votes
1answer
266 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 ...
3
votes
2answers
117 views

What preconditions should be checked while adding/removing a listener?

Imagine the following interface: interface Service { addListener(Listener l) removeListener(Listener l) } Should I check for null values while add/remove? Is it a good idea on remove to ...
0
votes
2answers
183 views

Using Constructors in Java

I would like to know why do we need to use constructors in examples like this:http://math.hws.edu/eck/cs124/javanotes5/c5/s2.html. I think even if there are no constructors the programs mentioned in ...
3
votes
0answers
102 views

What is the advantage of 'SwingUtilities.invokeLater()' method?

For the below sample GUI program using javax.swing, public class UnResponsiveUI extends JFrame{ private boolean stop = false; private JTextField tfCount; private int count = 1; /* ...
3
votes
1answer
160 views

Type Casting in Java

Could anyone explain why short(100000) is -31072 as said in p.48 of java-notes.The article says that "the value -31072 is obtained by taking the the 4 byte int 100000 and throwing away two of these ...
0
votes
1answer
331 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
0answers
22 views

What does 'name' attribute signify in any java.awt component?

With the below program, am trying to find the names assigned to all the components part of the GUI. public class AWTCounter extends Frame implements ActionListener{ private Label lblCount; ...
-2
votes
0answers
28 views

Why 'JRootPane' is-a 'JComponent' in javax.swing? [duplicate]

As per below code, I see that, setLayout() is being called on a JRootPane object instead of JFrame top level container in javx.swing world unlike java.awt, because it is told that swing's JFrame is ...
0
votes
1answer
130 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 ...
0
votes
1answer
167 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 ...
1
vote
4answers
127 views

Is there an alternative to instanceof when filtering a Java stream by class?

I have an unexpected situation in a project in which all types extending one class are packed into a Java collection; but only a specific extension of that class contains an additional method. Let's ...
3
votes
1answer
86 views

Why 'JButton' is-a 'Container' in javax.swing?

As per the class hierarchy in java.awt.*, class Button & class Label is-a class Component, and Component is not a Container, which make sense to me. As per the redesign of class hierarchy in ...
0
votes
4answers
211 views

Can a Java interface declaration enforce parameter properties?

As far as I know, declaring an interface is like so: public interface Roots_Squares { public double square_root( double value ); } Now... how do you enforce value to have non-negative values? ...
0
votes
1answer
20 views

Query on usage of 'Window()' default constructor from java.awt

I had been through this query before asking this question. In class Window we have constructor with default direct access level package private but not private as shown below: Window() throws ...
17
votes
3answers
3k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
47
votes
7answers
31k views

Why use try … finally without a catch clause?

The classical way to program is with try / catch but when is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do ...
9
votes
3answers
9k views

Naming conventions for instance, local and parameter variables

I was discussing with a senior developper coding conventions to apply to our projects (mainly Java/JEE projects). I disagreed with one convention he proposed: Instance variable names should start ...
2
votes
1answer
162 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 ...
3
votes
2answers
375 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
2answers
62 views

Class template specialization for implementing Automata

I'm implementing classes for simulating and generating different kind of automata. I'd prefer to use the same State and Transition classes for all the automata: NFA, DFA, PDA, etc. For a PDA a ...
11
votes
4answers
556 views

Why shouldn't a method throw multiple types of checked exceptions?

We use SonarQube to analyse our Java code and it has this rule (set to critical): Public methods should throw at most one checked exception Using checked exceptions forces method callers to ...
1
vote
2answers
52 views

Query on Recursive composition

For the below relation between Container and Componentin java.awt class hierarchy, I see that, in addition to is-a relation, class Container has composite relation with class Component with below ...