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
3answers
113 views

Why Double.parseDouble(“ABC”) not returns Double.NaN?

This code: Double.parseDouble("ABC") throws a NumberFormatException. Why is it wrong to expect a Double.NaN (NaN is literally Not-A-Number). A working example is this: public static void ...
-6
votes
1answer
50 views

Im a noob in programing and i tryed to create something like a rpg game can you tell me what you think about it and tell me if i can change anything [on hold]

import java.util.Scanner; public class JAva1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); float MAtP, MSpP, MCHit, MHP, MSpeed; ...
4
votes
1answer
161 views

Small code, big test

I have this code in a controller of an MVC implementation: public void execute() { try { String path = userSelectsFile(); if ( path == null ) return; //Just returns ...
0
votes
0answers
48 views

Best practices for programmatic describing of behavior of complex input forms

We have a complex web form (we use GWT/GXT stack) with lots of input elements of different types (text fields, selects, checkboxes, buttons), and behavior of these elements depends on each other. Now ...
-2
votes
0answers
20 views

Good tutorial for Atmosphere? [on hold]

What is your favorite tutorial for Atmosphere framework (async-io.org)? It's not much fun (for me, at least) trying to glue together atmosphere-examples and bits of info scattered through atmosphere ...
2
votes
5answers
663 views

Is it possible to make some methods invisible/non-usable to some classes in Java?

I am developing an application in Java whereby I would like to pass an object as part of an interface into other methods of classes written by other developers in the team. The object I'm passing in ...
1
vote
0answers
27 views

Java MVC: multiple use of the same event for different actions

I am working on a large Java project which employs the model-view-controller pattern. Should I use a different event for each action (to let the views communicate with their respective controllers)? ...
0
votes
1answer
42 views

Is there an established pattern for associating a database entry with a Java class that executes on that data?

I have a behavior tree with different leaf nodes that execute tasks. When building out the tree relationship in the database I need an association between the leaf node entry and the Java class that ...
0
votes
1answer
35 views

Architecture question about data migration

I'm facing a new enterprise project in Java about data migration. I did one of them in the past, now I want to do a better work and I think I need your considerations. So, let's me explain the ...
-4
votes
0answers
24 views

Cross platform application framework [on hold]

I am planning to develop a cross platform application that will run on all operating systems mainly windows desktop, Mac desktop, android and Apple mobile devices. What are the cross platform ...
-4
votes
0answers
35 views

I want to switch my programming platform [on hold]

I have worked as a ASP.NET developer(Web) for 4 years and I waked on Desktop applications as well(WPF). As everyone knows many things are taken care by .net framework and by Visual Studios, as days ...
-3
votes
1answer
38 views

How should I change in get method without calling getList() of Deque? [on hold]

import java.util.List; import java.util.ArrayList; public class Test { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { ...
1
vote
2answers
113 views

Is it better to perform a calculation in the field's setter or have a different method?

I'm implementing a simple Quota object which determines a usage percentage based on the maximum and the used. private int maximum; private int used; public Quota(int used, int maximum) { ...
0
votes
1answer
94 views

Enum as singleton or fully functional class [duplicate]

Joshua Bloch claims that "a single-element enumeration type is the best way to implement a singleton" Why? I totally disagree with this statement because enumeration is data type with some ...
-2
votes
0answers
37 views

Design pattern for Login Online and offline [closed]

I am new to Software Design patterns, I am developing an application in which user may liggedin offline or online depending on internet connectivity... so which design pattern will be best solution ...
-3
votes
0answers
27 views

Suggestions for Subscription-Based Software Product Licensing [closed]

Can anyone suggest some solutions or products for doing subscription-based software product licensing? We have used dongle-based solutions in the past but, with the proliferation of virtualization, ...
-1
votes
0answers
37 views

Advice needed on Selecting Server VS Cloud [closed]

I am having a big issue. Imagine that I am planning to launch a local social media site. You know what it is, multiple users, lot of data uploads (ie: photos, notes, etc). However I am having a hard ...
-1
votes
0answers
16 views

How BeanPropertyRowMapper works internally in spring?

I know that BeanPropertyRowmapper use setter method when I fire select query but is it uses getter method too or not ? I don't want to make my custom row mapper or hibernate or JPA. I have face below ...
-4
votes
0answers
49 views

About primitive types in java [duplicate]

I see that Java has Boolean (class) vs boolean (primitive). Likewise, there's an Integer (class) vs int (primitive). What's the best practice on when to use the primitive version vs the class? Should ...
-2
votes
0answers
43 views

Java : Error: A JNI error has occurred, please check your installation and try again [closed]

I am trying to run a new application which requires Java (Kaazing) and keep getting this error on startup "Error: A JNI error has occurred, please check your installation and try again" I have ...
0
votes
1answer
109 views

Should I use one class that calls Several static methods or several classes each calling one static method

I need to use instances which represent mathematical functions along with their parameters end enable their evaluation. I can take 2 approaches: 1: have a single class representing all the math ...
1
vote
0answers
29 views

Individual methods or parameters for Google Analytics abstraction on Android

A coworker and I are having a discussion around the best way to build our abstraction on top of Google Analytics for an Android application. A couple of data points. We have auto-tracking enabled ...
-4
votes
0answers
50 views

Sending binary data along with a REST API request [closed]

The problem is I need to send binary data (for example multiple images) and some metadata information together. I am using REST based web-service.
1
vote
0answers
91 views

Finding ArrayList elements in ArrayList [migrated]

I have two ArrayList userActions and actionsToCheck of type enum Action. I want to check if all the elements in actionsToCheck is present in userActions. Is the following good enough or is there a ...
-4
votes
2answers
100 views

it is possible to implement keyloggers in java [closed]

I am researching on keyloggers and as a part of my research I would like to know if its possible to implement keyloggers in java edit * How can i create a keylogger in java or to be precise what ...
1
vote
2answers
143 views

How to add rigor to my testing?

I work on a small/medium sized Java application. Over time, I've tried to ensure that the tests which I write are "good" tests, and that there's plenty of them. Hence I've been looking into various, ...
0
votes
2answers
102 views

Printing to out vs Logging, given the nature of this app?

I'm writing a command line application in Java. That app will scan a list of remote resources, do several attempts to access those resources, report failed attempts, and if succesfully accesed, ...
0
votes
1answer
105 views

Implementing a NoSQL and RDBMS compatible DAO

What would be the correct way to design a DAO which implementation is first going to be targeting a MS SQL database with a STAR model, but yet, business requirements specify the application must be ...
0
votes
2answers
72 views

Classic ASP to Java UI Conversion

My question is based on a business model of a financial services organization that currently is supporting applications that are a hybrid mix of Classic ASP and Java, with some JSP’s already in some ...
0
votes
2answers
100 views

Saving to file before storing into a database in a REST service

A mobile back-end I am building should receive a larger amount of data (some sensor recordings) from an Android phone. The phone does not have much use of it so it was most efficient to store the data ...
1
vote
1answer
103 views

Automatic Type Promotion in JAVA

I have started studying JAVA . In there, byte ch=50; ch*=2; works fine. But byte ch=50; ch=ch*2; does not. error:possible loss of precision required:byte found:int Why this do not happen ...
13
votes
7answers
2k views

Is there a pattern for a more “natural” way of adding items to collections? [on hold]

I think the most common way of adding something to a collection is to use some kind of Add method that a collection provides: class Item {} var items = new List<Item>(); items.Add(new ...
1
vote
4answers
160 views

Options for constructing an object that is not logically initialized until all fields are set

I am working on a Pokemon game at the moment, and am running into some design concerns. The easiest example is as follows: Each Species of Pokemon has several traits that are required before it is ...
3
votes
3answers
474 views

Should I try it straight or should I first check if it can be done?

I have a set of items, and each item in the set must be unique. Item are composed from multiple properties and each property of each item can be changed. But after each change every item in the set ...
1
vote
2answers
86 views

Java applets with Safari on Windows as compared to Safari on OS X [on hold]

I have a developed an Applet which works fine on Chrome/IE/FF on Windows. I am not expecting any users for Safari on Windows but there might be the odd user who may be on a Mac. As of now, I don't ...
3
votes
4answers
356 views

Are `switch` statements generally used wrong? [closed]

I see most developers using switch statements with breaks in each and every case. Is this usage of switch statements inappropriate since a simple set of if-else statements would suffice? Is it OK for ...
0
votes
1answer
95 views

How to make my program do something when an errors pops up instead of crashing?

Basically i'm writing a game in Java where i want the program to tell the user that he can't move right or left if that move will cause the player to move out of the array, which means this: ...
0
votes
3answers
128 views

Should I be extracting strings from source in core java the way android does?

I just started doing android development stuff after getting pretty comfortable with Java. Android apps tend to do this weird thing where they have all strings for their program held in an XML file ...
-1
votes
0answers
28 views

Problem in Javafx: Pane actions are mirrored on other panes [migrated]

I've recently been trying to create a small 2D physics sim using javafx. Ive created a new class Entity the extends Pane. After adding all the entities to the game engine, I found that if i tried to ...
0
votes
0answers
47 views

Tic-Tac-Toe Java : Button Issues [migrated]

I've created a little TicTacToe game in Java and I figured to write more effcient code, I'd make a for loop to create the 9 buttons. The issue I'm having is figuring out how to test now which button ...
0
votes
1answer
100 views

ActiveRecord equivalent in Java [closed]

My question is fairly simple.. What is the closest ORM to ActiveRecord that I'd be able to find for Java? In other words, in terms of thinking patterns and knowledge, with limted development time, ...
2
votes
3answers
147 views

Good or bad idea to create a “fromJSON” static factory constructor for an object that is often created by parsing a JSON coming from API?

I have a "Product" POJO class in my app. A Product object can either be created in-app by the user or by parsing a json that comes from the API. Product has 20+ fields, but Im using only 2 here for ...
1
vote
1answer
103 views

Adding a graphical view to a system

I currently have an program in Java that simulates railway movements. Essentially, trains arrive on platforms, pick up and drop off passengers, and then proceed, respecting signalling where possible. ...
4
votes
5answers
464 views

Should I create a single object for a common method call or use a throw away approach?

I'm creating a little rpg fight program just for fun and to practice my java (I'm pretty new hehe). I have a class called Dice with a method called d20 that rolls a random number between 1 and 20. ...
1
vote
0answers
121 views

How to separate out below tightly coupled classes

I have two classes which are somewhat tightly coupled to one another. Lets call them A and B. A derives from C and B derives from D. B is the class whose instance is created by the system and then B ...
0
votes
4answers
228 views

Identifying user of a webapp

For a small webapp I want to be able to identify a user. The issue is, if the user cheats in some manner, I want to be able to forbid him the usage of my application. I already have done extensive ...
1
vote
1answer
64 views

Limiting complexity in JPA programs Java/Hibernate

I've been working on a new application for some months now. It's my first big JPA program, and is still in the early stages. However, the complexity of my JPA object tree is becoming a growing ...
1
vote
2answers
77 views

How to randomly get or find a sub-tree (include root node) from a given tree that contains n leaf-nodes

I have a non-binary tree. I want to randomly find a "sub-trees" that are connected from root to leaf which must have at least n leaf-nodes (leaf-nodes of sub-tree must be leaf-nodes of given tree). ...
0
votes
0answers
2 views

How to display the decrypted file in Java without File Output? [migrated]

I am trying to develop a system that will decrypt a file then allows the authorized user to view it without saving the decrypted file. This is to ensure that the other user won't be able to open the ...
0
votes
1answer
65 views

Controlling concurrency by Thread Pool in scenario of CPU-intensive and I/O intensive requests?

My goal is to understand how to handle jobs coming from the client side at very high frequency each job is either CPU-intensive or I/O intensive, but both types of jobs are continuously arriving at my ...