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
1answer
124 views

Elegant way to count the number of files in Zip archive

I need to count the number of files in several zip archives for error checking. I've found several answers on SO but nothing elegant. I currently have the following code which works but it's not ...
1
vote
2answers
79 views

best practices for packaging in Scala projects?

Scala runs on the JVM, but that doesn't mean we have to write it like Java. Eclipse discourages use of the default package. What are some considerations (e.g. size of project) that determine how ...
1
vote
0answers
75 views

How to loop through array bidimensional in diagonal according to a position in degrees

The title could be no self-explanatory enough but I need some conceptual help in order to implement a solution to go through an array: I'm developing a program to calculate the "most shadepath" route ...
58
votes
5answers
6k views

What exactly makes the Haskell type system so revered (vs say, Java)?

I'm starting to learn Haskell. I'm very new it and am just reading through a couple of the online books to get my head around its basic constructs. One of the 'memes' that people familiar with it ...
0
votes
1answer
68 views

Converting from byte[ ] to user defined type

I am working on a network simulator designed in java with the basic function of routing messages through a network. I am trying to take a Message object, encrypt it using an encryption utility that ...
0
votes
0answers
30 views

Can't figure out how to parallelize the calculation of the amount of offspring expected for species in genetic algorithm

I developed a genetic algorithm in java 8 taking advantage of its reasonably free parallelism opportunities with Streams. As you are likely aware, running the epochs takes its time for even a test ...
2
votes
1answer
75 views

Internationalization on a service layer of an application

My specific problem is how to handle internationalization of specific messages from an architecture layer that is not the view layer(e.g service layer). I've created an architecture based on ...
-2
votes
0answers
16 views

JComboBox to auto suggest in java se [migrated]

I want to know how to get an JComboBox to auto suggest the elements when we type in the combo box. For an example, If I had loaded a JComboBox with these names using MySQL, [Amila, Nimila, Nikila, ...
-3
votes
0answers
8 views

I am getting org.hibernte.InvalidMappingException: unable to read xml when i try to run my program [migrated]

I am a beginner to Hibernate and cannot understand in which part of my program I have made an error. Can anyone please tell what may cause this type of error : org.hibernte.InvalidMappingException: ...
0
votes
1answer
33 views

How do I effectively test, and log, network status with a Java Application?

I want to write an application (in Java) that basically detects when I lose my internet connection, and then log the time. To make things more challenging, I'd like to figure out the point of failure. ...
1
vote
0answers
69 views

Finding the closest n points to any arbitrary point in two dimensions (r-tree, quadtree, spatial index)

I have a distribution of two dimensional point objects. How is it possible to find the nearest N number of points to any given point without iterating over the entire collection of points (and only ...
0
votes
1answer
63 views

Serialization - can the output from a serializer be modified and then de-serialized

I am trying to serialize a Message object using ObjectOutputStream ,take the byte[ ] output of the serializer,encrypt it using an encryption tool and then trying to de-serialize it and cast it as an ...
1
vote
1answer
93 views

How can I find what Resources a Java EE container provides?

How can I find what "Resources" a Java EE container provides? Can I discover this programmatically, or is there documentation I should refer to? (Note that the Java EE tutorial is vague on this ...
3
votes
3answers
304 views

“One of some”-type

Say that you have some different classes that does not really have any functionality in common, but somewhere in your program, you need one of them (which one is not necessarily important) because ...
0
votes
0answers
23 views

Is this code Clean, Effective and SOLID? [migrated]

I've recently read the books Clean Code and Effective Java. I am a huge fan of Object-Oriented Java. I am trying to write as professionally as possible. I have been an Android Developer for 20 months ...
1
vote
2answers
36 views

Testing code in Java that is only loosely defined

My question is about testing in general. At school, professors say that testing has to be written before we begin to write some code. I guess we need to use EasyMock to represent the classes not ...
2
votes
1answer
94 views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
5
votes
3answers
191 views

Is it conventional to name final/constant local variables in UPPER_SNAKE_CASE?

Pretty simple, I have a method: public final void myMethod(User user, Group group) { final int MAX_USERS_PER_GROUP = group.getMaxUsersPerGroup(); int usersInGroup = 0; // Get users in ...
3
votes
1answer
136 views

Recursively parse without resorting to ugly design patterns

I'm currently building a crochet pattern parser in Java, and I've hit upon some trouble. I'll call the language used for input Crochet Pattern Code (CPC). I have a rather large writeup on the ...
2
votes
0answers
66 views

Fixing years of bad coding [duplicate]

Last year I got my first job with an I.T. company developing industrial Android applications. Unfortunately, when I got there and started working with the code base I was repeatedly confronted with ...
-5
votes
0answers
66 views

Breaking out of an for statement in Java [migrated]

If i do something like this boolean ret; for(int i = 2;i<30;i++) { if ( 30%i == 0){ ret = true; } else { ret = false; } } ret becomes true allready at 2, but also at 5,10 15, is ...
2
votes
2answers
72 views

Creating an auto-patching system for Spring Hibernate Application

I have this question for few months now. We have a web application which has monthly changes and weekly bug fixes if any. Usually we just build the new war, undeploy the old ones and redeploy new ...
6
votes
6answers
589 views

Why are my unit tests so expensive? [duplicate]

I am a Java developer, working on a small project. We are three people in the team, we have a budget for 3 months of coding (+ some time for the Analyst, Project Manager and QA team). It is a small ...
0
votes
0answers
32 views

handling external events in a cluster environment

I have an app written with JSF and Spring using JPA+Hibernate which is running on a Glassfish4 server. Right now I have an Observer pattern which is listening for some Postgresql events. Let`s say ...
0
votes
0answers
4 views

Help with removing circles from javafx pane when clicked [migrated]

I have an assignment for school where i have to make a pane and then make circles appear when i click them, and then remove them with right clicked. this is what i have so far ...
0
votes
1answer
94 views

How to structure programs that interact with databases? [closed]

I've just finished a book on MySQL and I'm in the infantile stages of learning to couple that with Java. I know that the technology I need to learn is called JDBC and that it essentially allows you to ...
7
votes
3answers
1k views

What is the difference in memory between a variable assigned to null and one not assigned

What is the difference in memory between a variable assigned to null and one not assigned? I know that there is a difference in usage, but what is the difference in memory?
-4
votes
1answer
72 views

improve optical character recognition of image using Tess4J [closed]

How to improve optical character recognition of image using Tess4J ? Some case have unstable result especially when you have text inside image. there is my code : try { ...
4
votes
1answer
118 views

Parking Simulation Software Design

I've been requested to develop a quite well known problem for a job interview. The Parking Simulation which an example can be found here. I came up with some ideas for which design pattern should I ...
0
votes
0answers
13 views

Is Java JNLP codebase entry required in the jnlp tag? [migrated]

I have an applet that needs to be served from 50 different servers in an M2M network. The following line in the jnlp file will work <jnlp spec="1.0+" ...
0
votes
1answer
74 views

Making a database and related operators using files and JSON in java [closed]

I'm trying to write a program that reads operations from a file. these operators look like below : CREATE TABLE student(id:integer, gpa:decimal, name:string, family:string,isMale:Boolean) INSERT ...
0
votes
1answer
108 views

Using XML to store and edit data records in Java

I want to use XML to store data for an assignment . In this Java assignment I'll get data from the user in form of lines in a file below INSERT INTO student(id,name,family,isMale) VALUES ...
0
votes
1answer
162 views

Should I always call super in Java? [duplicate]

Anti-pattern considerations aside, should I always call super in Java when overriding methods, even when the method is empty? Take a look at the code below, this is an excerpt from AsyncTask and can ...
0
votes
1answer
97 views

Architecture for my Java application [closed]

I try to create small Java tools to help me at my work every now and then. Usually these do not have to be pretty and I find myself coding a single, sometimes massive, Java class. However, now my plan ...
-2
votes
1answer
48 views

Reading from html page that needs cookies passed and form data [on hold]

I am writing a program in java in order to practice tough coding problems and learn more. Program description The program reads first names from a text file one by one, then enters them into facebook ...
2
votes
1answer
68 views

Advantage of Declaring and Initializing Different Object types?

I am learning how to use java to program, and am just learning about abstract classes and how they are useful. Say I have a class which extends another abstract class, which has 2 methods, one of ...
1
vote
2answers
99 views

Pattern for validating rules having different signatures

I have a class in charge of responding to an input event and maybe triggering another event. To decide, it has several rules to check. I'm trying to get away from a class looking like this: public ...
2
votes
2answers
136 views

When to use ANTLR and when to use a parsing library

I've always wanted to learn how to write a compiler - I've decided to use ANTLR, and am currently reading through the book (its very good by the way) I'm pretty new to this, so go easy, but the jist ...
27
votes
6answers
4k views

Dynamic Code Evaluation in Java - Clever or Sloppy?

I am trying to create a flexible ACL framework in Java for my application. Many ACL frameworks are built on a whitelist of rules, where a rule is in the form of owner:action:resource. For example, ...
1
vote
1answer
37 views

DataThread class that doesn't extend Thread, poor naming?

I created a DataThread class that doesn't extend a Thread, but has one as a member variable. Favor composition over inheritance, is a rule that I heard of, but I am thinking that the name of the ...
0
votes
0answers
40 views

what is the relationship between CORBA, JMS and MDB?

In the context of my previous fuzzy question on microservices, please help me break down the terminology involved in these technologies: CORBA JMS MDB Utilizing JNDI, I believe it's possible to do ...
-1
votes
1answer
35 views

What's the best way to implement a real time show board to show results from concurrent result producers in Java?

I'm making a load test tool that launches multiple thread to simulate load on the target server. Each thread executes a predefined set of commands in the structure of TestSuite - TestCase- TestStep ...
0
votes
2answers
73 views

How is the best way to work with step by step documentation to software maintenance [closed]

I'm working on a web project in java and I have a problem with the documentation we are making. The goal is to has step by step how to do some basic stuff for system maintenance, like add fields to a ...
1
vote
1answer
88 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
5
votes
1answer
193 views

Sometimes, “programming to interfaces” introduces possible (and avoidable) runtime exceptions?

Please consider the com.google.common.collect.ImmutableMap Programming to its interface, Map , creates a bug that could blow-up in the runtime as such: Map<String, Integer> myMap = ...
2
votes
2answers
105 views

Immutable vs Read-only vs Unmodifiable naming difference

So, I've looked at some similar questions asked here in regards to how these three should be used in naming. Usually, the answer is something along the lines of "it's conventional" and "just be ...
1
vote
2answers
101 views

OOP (possibly Java-specific): Comprehensive Set of Method Categories [closed]

I am working on a coding convention to follow for my Java projects. I find it easier to find my way through a class when I group its methods by category. For example, rather than having each ...
1
vote
2answers
68 views

Is it a good idea to contextually name predefined functional interfaces?

I am currently working with Java 8 and using functional interfaces a lot. I often find myself writing code like this: public interface MessageHandler extends Consumer<String> { } Is this a ...
2
votes
3answers
160 views

Documenting intent Vs knowledge

It is said you should document the intent of your function or class which I agree with. However recently this line became a little bit blurred when I was wanting someone to document why this ...
0
votes
5answers
197 views

classes/inheritance, how do I handle special cases that require more change

I often find myself in this situation where I have a base class that does a lot of graphics. There are, for example, three strings that are positioned top, middle, bottom of an element. Like a scale ...