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.
2
votes
0answers
50 views
Are we abusing static methods?
A couple of months ago I started working in a new project, and when going through the code it stroke me the amount of static methods used. Not only utility methods as ...
-4
votes
0answers
14 views
how to implement TextWatcher when my Json is ready?
I am facing problem with my project, I want to connect my app to local host, I have seen the ways to do that and picked up the simplest one using json, thus I stopped on the way of implementing my ...
-2
votes
1answer
53 views
Is it reasonable to use Jersey-Framework for an nonRESTful / unRESTful web service?
I'm planning to build a web service that receives an XML and a few Images. The web service then builds an HTML out of it. That is the only thing it should do. For that want to use Jersey because of ...
0
votes
3answers
67 views
How to represent an object with actions that can only be used in a specific situation?
Let's say I'm designing an RPG type game, and this game has a turn-based combat system. There are some things that the player character/non-player characters can do inside and outside of combat. For ...
-2
votes
1answer
33 views
How to display a non-interactive message on a JFrame? [on hold]
I'm writing this code here:
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.UIManager;
public class FirstJavaClass {
public static void ...
-4
votes
0answers
35 views
Importing my class to a given “tester” class? [on hold]
In Java I have created a class with a HashMap where I put 13 values. With it's own main it will display the RGB values of the Color Object. The problem is trying to import it to use with a given ...
-3
votes
0answers
36 views
Choose an application development environment for the displaying / monitoring data from multiple servers
There are three server ports that are used for communication between the client and the network operator and interact through transmitters. It is necessary to develop the program (maybe framework) for ...
-4
votes
0answers
20 views
logic of Ap to return number set to bit1 as an input binary [on hold]
public class BitSet1
{
public static void main(String[] args)
{
double num=(Math.pow(2.0,31.0))-1;
int num1=(int)num;
double outnum=num1;
int count=0;
...
-4
votes
1answer
35 views
How to get number of network interfaces in Java [on hold]
How can I get the count of network interfaces?
I don't need to list them, I just need the count, so if the program detects there are more than 2 network interfaces it can do something different.
0
votes
0answers
31 views
Customizing xmlAdaptor in JAXB
I have hashtable which contains columnName and column value. My hashtable contains key,value pair as like
columnName = columnValue
columnName = columnValue
columnName = columnValue
columnName = ...
0
votes
0answers
51 views
Calling a method on a constructor method [migrated]
I saw this line of code while doing an Android tutorial, and it compiles:
Date date = new GregorianCalendar(year, month, day).getTime();
How can you call the getTime() method on a constructor. To ...
2
votes
1answer
144 views
What are modern develop-deploy-test techniques for non-interpreted languages?
I have strong web-developer background, where in order to show client a demo I've uploaded a solution to demo environment and sent over a link. If case client asked to make changes, I did them in ...
1
vote
1answer
137 views
Is it true that JVM language is difficult to integrate with C than other language? [on hold]
I have seen many libraries provide high level API in the language like python or lua. For example:
The linear algebra library "Trilinos" provides a python API.
The deep learning framework "torch" ...
-3
votes
1answer
67 views
Which is best practice to save uploaded images in a database or in a folder [duplicate]
I am developing a project in jsp and servlet and I am using mysql database, I want to upload many images from my application but I am confused where I save uploaded images in the database or in a ...
3
votes
2answers
98 views
Is an attempt to create a duplicate resource, e.g. a user, worthy of throwing an Exception?
Say I have an REST API for creating users in an application. The request goes to a controller, which marshals the request data into a domain object, and passes it to a service to create a user.
Now, ...
-4
votes
1answer
60 views
List of differences feature between OracleJDK and OpenJDK? [closed]
There are some differences between OracleJDK and OpenJDK, even though it's very close. But can I build the same powerful program that I build on OpenJDK as the same as Oracle JDK?
Is there the list ...
-4
votes
0answers
61 views
How to create a bot program that interacts with a chatsite [on hold]
Background info:
Basically there is a chat site: www.teenchat.com
And there is a karma system, when users are active there for 6 hours, then they get 5 karma. Users can gift karmas to other users by ...
1
vote
0answers
43 views
Creating duplicate instances of objects for timeline functionality
I am working on a Spring-MVC based project, in which I would like to add Timeline functionality. The most important object in our project is the Note, there are objects associated with it like ...
1
vote
0answers
99 views
OOP - Modeling a Chat Design Review [closed]
Seeking thoughts on the following design.
I know the design could be lot simpler if use Sockets. But I wanted to think of a design with pure POJO classes.
User
string id;
string displayname;
...
1
vote
1answer
68 views
Determine what to draw based on neighbour tiles?
I have a tilemap and I want to add walls to it. I painted 16 images, one for each possible combination. For example:
A lone wall tile would get a image that has walls around.
A corner would get ...
-2
votes
0answers
87 views
How can I find out what's happened to a JDK bug I've filed? [closed]
I've filed a couple JDK bugs in the past few months, and received the boiler-plate "Dear Java Developer, Thank you for reporting this issue" email, which includes a "Review ID", but says it will not ...
1
vote
1answer
95 views
Using Spring in Java Project
I've got a question about a correct usage of Spring.
I know that some people use the DI "aggressively" so that they always use spring and completely eliminate the usage of word "new" in the ...
0
votes
1answer
166 views
Concepts of package and module in java 9
Java 9 will have both packages and modules. Modular system developed within project jigsaw.
The main goals of it (JSR-376):
replace classpath with explicit dependencies, and;
prevent access to ...
-5
votes
0answers
40 views
Search file for string and assign variable to 8 characters after the string has been found? [closed]
I'm attempting to read a log file in java. The log file will output as shown:
SMILE-RESULT::ORIGIN=libsvm::TYPE=regression::COMPONENT=arousal::VIDX=0::NAME=arousal::VALUE=-2.213931e-01
...
2
votes
1answer
72 views
How to handle shutdown/startup of a Java application that relies on real time events?
I have this Java project called Server. Server is essentially a single-threaded application that listens to events from external applications. These events are crucial and missing one is a huge deal.
...
1
vote
1answer
115 views
Is it OK to do IO inside java 8 streams?
Example to question in title:
List<UUID> ids = dao1.getContactsOfUser(userId);
List<String> contact_names = ids.stream
.map(uid -> dao2.getContactByUid(uid)) //is it ok?
...
1
vote
1answer
146 views
Log4j logger per class vs logger per application
I am stuck at understanding a concept related to Logger creation, especially in the context of Java EE.
In my experience, I nearly always used one logger per application, with few cases when I needed ...
3
votes
1answer
86 views
Is it unreasonable to implement a small domain specific scripting language?
At my new job, they are currently spending scores of labor hours that we don't have to do manual QA testing after every build. Nothing is automated at all. (We can only afford three developers, and ...
1
vote
2answers
64 views
How to sync the data from the same user across multiple devices
I'm working on a small fitness app in which the user (whom is authenticated with the a server) could create their own workout plan which will be synced with a server.
The problem with this is that ...
1
vote
1answer
63 views
Recieving errors without engaging in excessive communication when using sockets
I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of ...
0
votes
1answer
118 views
Should I use import java.util.* for bringing in just one class?
when we import the Scanner class to a program which is the best and most suitable method from these two?
import java.util.*
import java.util.Scanner
I'm a totally newbie to the programming and I ...
4
votes
2answers
126 views
Floating point calculation being too exact
In Java, I've run this method:
private static void floatAddition() {
float a = 0.1F, b = 0.2F, c = a+b;
System.out.println(a + " + " + b + " = " + c);
}
and the result is 0.3 for ...
5
votes
7answers
375 views
Is it appropriate to not follow the O/C principle if you have unit test coverage?
I find it more convenient to 'modify'existing classes rather than extending them. Thus, I violate the open closed principle of 'not modifying the compiled and tested source code, instead extending the ...
3
votes
2answers
110 views
How do you handle sequentiallity in API's?
Consider a use case of the form:
The system shows a list of potential filters (by name, by creation time...).
User chooses a filter and supplies necessary parameters.
System shows a list of ...
0
votes
0answers
55 views
Concepting a Server - Handling Clients/Connections
I am writing the Server-Side of an Application, just for practicing my Java programming skills. I have made an attempt to program it, but I am not satisfied with my solution and I think it is because ...
0
votes
1answer
129 views
How to save tuplas values, to later search on it
Scenario
I have some values of the type : (Name - Email)
From this couples of data, I have to set a ArrayList of "Name" values,something like: |Name1|Name2| --- |NameN| to set a Spinner. (Ordered ...
3
votes
4answers
238 views
Exception treatment with/without recursion
I've entered in an argument with a fellow colleague about a piece of code. While he thinks that it is ok, I don't. But I don't have any more arguments than that calling the same method (recursion) in ...
1
vote
0answers
60 views
is Command appropriate software pattern for this?
I have following task:
I need to send several instructions after each other to the hardware. Next instruction is never sent before either answer to previous instruction comes (valid answer or error) ...
0
votes
0answers
14 views
Conceptually, how should a unidirectional multivalued relationship be implemented?
Ok, I'm trying not to upset the programmers list, but not so successful so far. My apologies. I'm trying to understand, conceptually and based on experience, which is the correct way for a JPA ...
1
vote
2answers
194 views
Is it viable to copy contents of a database into a program's memory, if multiple queries take time?
The task:
I have a database with 4 tables with 200 rows, 800 rows, 50 rows and 30 rows respectively.
Just to simplify it, let's assume the tables are these sets:
A = [Ar1, Ar2, Ar3], B = [Br1, Br2], C ...
-2
votes
2answers
115 views
Java Integer - Immutable [closed]
I cannot understand the definition. Here's some code:
Integer iW;
for (iW = 1; iW < 4; iW++)
System.out.println(iW);
int i = iW;
iW += 6;
System.out.println(String.format("iW = %d, i = %d", iW ...
3
votes
0answers
65 views
Determine equality of a DAG
Given a fairly traditional node class (below), whats the best way to implement equality on a given graph?
If our node looks like this
public abstract class Node{
private final Set<Node> ...
2
votes
2answers
124 views
Generating Java Classes with Compile-time Value Parameters
Consider a situation where a class implements the same basic behavior, methods, et cetera, but multiple different versions of that class could exist for different uses. In my particular case, I have a ...
52
votes
4answers
6k views
Is functional programming faster in multithreading because I write things differently or because things are compiled differently?
I'm diving into the world of functional programming and I keep reading everywhere that functional languages are better for multithreading/multicore programs. I understand how functional languages do a ...
0
votes
1answer
126 views
Is it better to have one web app or multiple web apps
I am going to develop a server application to provide the functionality of a book keeping software in tomcat server. I can think of two ways to achieve this.
Creating a single web application - ...
5
votes
3answers
179 views
Doesn't returning a Collection as Unmodifiable / Immutable unnecessarily break method scope?
Let's say I create a Collection in an instance method. I do not assign that reference to any instance variables. Rather, I just return it to the invoker. Then, I exit.
Now, the only thing with a ...
2
votes
0answers
62 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
0answers
90 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 ...
1
vote
1answer
53 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 ...
0
votes
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 ...