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

4
votes
3answers
333 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 ...
6
votes
5answers
2k views

Should I use initializer blocks in Java?

I recently came across a Java construct I have never seen before and was wondering whether I should use it. It seems to be called initializer blocks. public class Test { public Test() { /* first ...
-2
votes
0answers
39 views

What are the limitations of Factory design patterns? How to overcome?

As we know there are many ways, by which we can break a singleton implementation in Java. Similarly do we have any ways by which we can break factory method implementation in Java? if yes then how to ...
1
vote
2answers
731 views

Shift bytes through a fixed sized buffer

I'm writing an InputStream that processes data streams containing "trailer" data. That is, the final n bytes of the stream is a piece of data that must be handled separately and shouldn't be returned ...
2
votes
1answer
70 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 ...
0
votes
0answers
37 views

Business logic - Server side vs client side

In my current project I have a screen which pulls data from several webservices, pulls data from db via backend api and checks that all resources have the same data. The other webservices are partial ...
1
vote
1answer
43 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
141 views

NoSQL in Java Enterprise Application

I'm planning a large scale enterprise application that requires reliability and standardization comfort that Java EE provides. At the same time, I'm wondering if I go for Java EE, will I be able to ...
-2
votes
0answers
50 views

How to use a class, located in another project? [on hold]

I need to use in the my current project a class A from another project (IDE – Eclipse). To do this I add this another project in "Java build path" tab "Project". Compiling was successful, but I get a ...
5
votes
3answers
8k views

How to open a desktop application through browser without a Java applet?

We run a cloud-based medical software, and a very important part of the program is bridging to an imaging software straight from our website, passing information through command line arguments. We ...
0
votes
1answer
100 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
votes
0answers
44 views

Sorting a 2d array in java

I'm a high school student who is interested in computer science, I asked this question to my teacher but she told me not to bother messing around with code and trying to understand how to modify ...
14
votes
9answers
12k views

Use constructor or setter method?

I am working on a UI code where I have an Action class, something like this - public class MyAction extends Action { public MyAction() { setText("My Action Text"); setToolTip("My ...
0
votes
1answer
111 views

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

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
36 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
45 views

Where could i find downloadable java netbeans sample projects [on hold]

I'm looking for some java sample projects, built with netbeans..I found few on netbeans and oracle sites..If you know anywhere i can get more open source examples please be kind to mention..thanks...
1
vote
1answer
30 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 -> ...
2
votes
0answers
24 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 ...
18
votes
6answers
3k views

Why did the team at LMAX use Java and design the architecture to avoid GC at all cost?

Why did the team at LMAX design the LMAX Disruptor in Java but all their design points to minimizing GC use? If one does not want to have GC run then why use a garbage collected language? Their ...
-3
votes
0answers
87 views

Which form of Java 6 resource exception handling is better and why? [on hold]

BufferedReader input = null; try { input = new BufferedReader(new FileReader(someFile)); input.readLine(); } catch (IOException ex) { ex.printStackTrace(); } finally { if (input != ...
27
votes
5answers
10k views

Is a lambda expression something more than an anonymous inner class with a single method?

There is a new hype with the long awaited lambda expressions in Java 8; every 3 day another article appears with them about how cool they are. As far as I have understood a lambda expression is ...
1
vote
2answers
142 views

Designing validation classes

This is a follow-up of this question. I decided to implement what the accepted answer suggests, however, I realized I also needed individual public methods for each member the entity to be validated ...
9
votes
5answers
11k views

Is it not a good practice to handle runtime exceptions in the code?

I am working on a Java application, and I see that Run time exceptions are handled in many places. For example, try { // do something } catch(NullPointerException e) { return null; } My ...
0
votes
2answers
63 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 ...
-3
votes
0answers
63 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 ...
-1
votes
0answers
37 views

Android - Information leakage flaw

I have developed an application in the Cordova Framework, and I have added a camera plugin for capture functionality. I am getting an Information Leakage flaw in the code below, using veracode to scan ...
0
votes
0answers
23 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
59 views

Divide java web app into smaller web app

I'm not sure if I should ask here or stackoverflow. Please let me know. I've a web application that consists of 3 main technologies: JSF, jax-rs and websocket. All three are coupled together with the ...
20
votes
3answers
3k views

Why should I use “functional operations” instead of a for loop?

for (Canvas canvas : list) { } NetBeans suggests me to use "functional operations": list.stream().forEach((canvas) -> { }); But why is this preferred? If anything, it is harder to read and ...
7
votes
3answers
185 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
36 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
115 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 ...
1
vote
2answers
97 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 ...
1
vote
1answer
381 views

JEE MVC, controller calls the interface instead of the interface implementation

I'm following this tutorial: http://wiki4.caucho.com/Building_a_simple_listing_in_JSP It creates a basic web application in Eclipse using the MVC pattern with Resin as the web container. Here's the ...
8
votes
3answers
869 views

How safe it is to do minor JVM upgrades?

I have been working on the JVM for years and I have very rarely experienced a JVM crash ... that is until approx 6 months ago. Since that I have experienced approximately 5 JVM crashes resulting ...
3
votes
2answers
589 views

Checked vs unchecked exception when validating documents in this service

I have a service that allow users to add dynamic content to a repository. So basically I have a generic Document class that contains a list of property for that specific object depending on what type ...
4
votes
5answers
17k views

Why is there no default constructor generated if you define an explicit constructor?

class Employee{ String name; int id; //No explicit constructors } Now I can invoke the following statement: Employee e1 = new Employee(); With the above code, the compiler will ...