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

25
votes
7answers
13k views

Why avoid Java Inheritance “Extends”

Jame Gosling said “You should avoid implementation inheritance whenever possible.” and instead, use interface inheritance. But why? How can we avoid inheriting the structure of an object using ...
-4
votes
0answers
19 views

Asynchronous method to search and download a file by FTP connection [on hold]

I'm developing a Java desktop application. I need an asynchronous FTP method to search repeatedly (for example, every 2 seconds interval) if exists a new file on a web server and, if so, it downloads ...
1
vote
0answers
59 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 ...
2
votes
0answers
35 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
1answer
1k views

Notify client about changes in database in Java

I'm working on a distributed client-server system that uses TCP. The program's functions is to transfer money to an from the server, but also between the clients, a sort of MobilePay. When one ...
-5
votes
0answers
63 views

Writing good Java [on hold]

Programming languages often have several legal ways to do something, and certain ways that experienced programmers tend to go. I’ve heard it called “idiomatic”. This is different from a style guide ...
-5
votes
0answers
18 views

Several alternatives to render image from STL files [on hold]

Can anybody here put some light on this post by giving some information of possibilities to render STL files into image? I am looking several possibilites either using some Java library/Blender ...
0
votes
2answers
157 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
3answers
564 views

Cache Json on disk with fast read back in java/android

summary: I need a way to cache a large JSONArray on disk, and be able to quickly read AND CONVERT it back to JSONArray at a later time. NOTE: my output MUST be a >>JASONarray<<, and not a ...
1
vote
1answer
40 views

Data Structure for Form or Survey

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 ...
-2
votes
0answers
28 views

Which one needs to upgrade first [on hold]

I have a situation, the question is which one to upgrade first Java or Tomcat. We are migrating tomcat 6 to 7 and Java 6 to Java8. Do we have any guidlines anywhere and which is the best way to ...
1
vote
0answers
50 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 ...
0
votes
2answers
129 views

Whether to use enum vs map vs config file?

I have ~30 resources each having ~10 attributes. I want to store some information about each attribute. Ex: its multiplicity, it RW (Read/Write), RO (Read only), longName, shortname. So I was ...
3
votes
2answers
291 views

Is turning a method into a class to use it across many classes bad practice? [closed]

Let's say I have a sort method inside of my class and another class that has no relationship with that class needs the same method. Instead of writing that method twice and breaking the do not repeat ...
0
votes
0answers
18 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' ...
-5
votes
0answers
23 views

java-gnome Builder: GtkSoureView invalid object type

I'm trying to use java-gnome with Glade but when I run it then Java write this error: Exception in thread "main" java.text.ParseException: Invalid object type „GtkSourceView“ on line 255 at ...
-6
votes
1answer
81 views

How to enable 'for-each' loop in my own linked list class? [closed]

Please guide me on code additions that will allow someone to iterate over a custom linked list implementation using "for-each" loop, just like existing collection classes or arrays. All I know is that ...
1
vote
1answer
471 views

How to efficiently handle related data in MVC?

Talking about MVC with servlets and JSP's, in a context about products and manufacturers , when querying the application for a list of products: the servlet loads a list of products from the ...
1
vote
1answer
86 views

(Spring) AOP Design of Transactions

In our application we have several transactions, where each step is extensively logged. Pseudocode: @Component public class OurServiceImpl implements OurService { ... @Transactional public ...
0
votes
1answer
386 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 ...
0
votes
0answers
22 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
15 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 ...
-6
votes
4answers
164 views

Java constructor: I can't understand [on hold]

I am learning Java and I have a problem understanding the concept of constructor for the field variables. What is the problem with the following code. It shows "null" as an output. public class ...
-4
votes
0answers
17 views

Getting directions using my own voice samples regarding a gpx track [on hold]

My goal is to create an app in android that loads a gpx track Compares my gps position to the track and gives me directions using my own voice (samples) as in Go to the right soon Go to the left ...
1
vote
1answer
207 views

Decoupled architecture in Android

I am building an app for Android that will have multiple data sources depending on who is using it. N-tier architecture with a repository pattern seems like the right way to go about this but I am ...
3
votes
1answer
110 views

what happens at Java interpreter level when IncompatibleClassChangeError is thrown?

I am a noob at JVM internals. Can someone explain what happens at Java interpreter level when IncompatibleClassChangeError is thrown? I am facing an issue similar to the one described here: ...
4
votes
2answers
1k views

Programmatically extending Hibernate table/entity definitions in Spring, how?

I would like to know if there is a way —maybe with 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 ...
15
votes
2answers
468 views

What are the reasons for why a Java/Linux stack fails to be “real time”?

I have often heard developers mention that Java can't "do Real Time", meaning a Java app running on Linux cannot meet the requirements of a deterministic real-time system, such as something running on ...
0
votes
0answers
29 views

How can I paint a custom circular JComponent without an “invisible box” around it? [migrated]

I'm writing a JApplet that displays a diagram with numbers in circles and lines connecting the circles. I've created a class that extends JComponent to act as the circles. I overrode the ...
5
votes
9answers
335 views

Why is using an optional preferential to null-checking the variable?

Take the two code examples: if(optional.isPresent()) { //do your thing } if(variable != null) { //do your thing } As far as I can tell the most obvious difference is that the Optional ...
4
votes
1answer
153 views

Detecting surface faces of a huge 3D mesh/grid

I've written a module in my application that creates a mesh from existing coordinate and face data. The number of vertices in the mesh could easily exceed 10 million and the same goes for the faces. ...
0
votes
1answer
88 views

Communicating with third party API

I am working on an App which basically communicate with a third party API, it has no back-end. The front-end will be a SPA. Here is the overall scenario: The external API needs current user's Id to ...
0
votes
0answers
20 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. ...
1
vote
1answer
39 views

TreeItem containing non-String object displaying strange text

Hello StackExchange community! This is my first post and appreciate any help anyone can offer. I'm new to Java, and I'm sure this issue is simply due to my misunderstanding of the fundamentals. I ...
2
votes
1answer
550 views

Emulation of MMU accessing the contents of the registers

I'm having a play around with emulating a simple old CPU. I've set the structure up, so far anyway, as follows: The device is the main and creates an instance of the CPU. The CPU then creates ...
51
votes
8answers
15k views

Why should I use a factory class instead of direct object construction?

I have seen the history of several С# and Java class library projects on GitHub and CodePlex, and I see a trend of switching to factory classes as opposed to direct object instantiation. Why should I ...
53
votes
7answers
24k views

Excessive use “final” keyword in Java [duplicate]

While I understand what the final keyword is used for in the context of classes and methods as well as the intent of its use for in regards to variables; however, the project I just started working on ...
-5
votes
0answers
39 views

Measuring sound frequency [closed]

I've been looking around for a Java API that measures the frequency of the sound, the project idea is to browse an audio file from the computer (contains only piano music) and to convert these music ...
3
votes
1answer
73 views

How to access environment-specific configuration in an enterprise application?

My application is a generic enterprise application which can be deployed on any application server running on any OS. I don't know how/where to configure my application, except for the database ...
3
votes
1answer
708 views

Do I need JUnit tests for the controller layer on a MVC when I have a database layer

I have a MVC which has this structure: ui controller db model Basically the controller doesn't really do much more than connection ui with db layer. Do I need to provide JUnit tests for the ...
-2
votes
3answers
145 views

What is the most elemental workflow for TDD?

Gradle is such an interesting build tool that it prompted me to look at Spock and JUnit -- which I've never done before. What is the basic workflow with TDD? My approach has been to do frequent ...
-2
votes
0answers
43 views

Android App - GPS Help [closed]

I'm currently working on a project that includes making an app for android phone using the phone's GPS. I'm looking for some insight into how to approach the project. The app needs to receive a ...
1
vote
1answer
47 views

Service/component based application in Java

I have a Java project whose architecture is quite component-oriented, and I am wondering if this is a common way to organize code which rules/patterns are used, if there is a name for this coding ...
-1
votes
1answer
225 views

In which cases and examples String in Java is not immutable? [duplicate]

If Strings are immutable in Java, why is the output of this code 2GB, instead of 1GB? class Laptop { String memory = "1GB"; } class Workshop { public static void main(String args[]) { ...
1
vote
0answers
30 views

Handling multiple rest api versions within Android Java client

Actual architecture I have an app where a model is attached to every activity. The model ask a repository for information that can come from server or local db depending on many factors. When it asks ...
1
vote
2answers
91 views

Which layer should validation located?

I'm creating Rest API using (Spring Boot) and i using Hibernate Validation to validate request input. But I also need other validation, example when update data need to check, if company id not ...
2
votes
1answer
57 views

How to paginate local and remote data?

My team is currently facing a problem that we don't know how to tackle. Some technical details: we use Java 8, Hibernate, Spring, MySQL, and AngularJS for the front-end. We need to do pagination on ...
5
votes
2answers
185 views

Is it an antipattern to use peek() to modify a stream element?

Suppose I have a stream of Things and I want to "enrich" them mid stream, I can use peek() to do this, eg: streamOfThings.peek(this::thingMutator).forEach(this::someConsumer); Assume that mutating ...
32
votes
8answers
7k views

Is it an antipattern, modifying an incoming parameter? [closed]

I am programming in Java, and I always make converters sort of like this: public OtherObject MyObject2OtherObject(MyObject mo){ ... Do the conversion return otherObject; } At the new ...
-2
votes
0answers
29 views

Java 8 on Weblogic 12.1.3, Weblogic roadmap [on hold]

I would like to upgrade Java to 8 from 7. We use Weblogic 12.1.3 and 12.1.1 I wonder if my web application would work with Weblogic and Java 8. What could be the problems? We are using JavaEE, JMS, ...