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
2answers
49 views

Java Web Application in Cluster with Shared Database. How to Negotiate an Instance to do Updates? How to Notify Instances of Updates?

I have a Java web application, running in a cluster of Tomcat application servers and a shared SQL/JDBC database. Data from the database is cached in memory in each instance of the web app. My web ...
0
votes
4answers
194 views

How to ensure objects unique by equality?

I frequently have this problem but didn't find it as an established programming pattern. I have some Class C whose equality is determined by some key k and I want to prevent time-consuming ...
0
votes
0answers
10 views

Design architecture and software for webapp integrating with few other endpoints (Email Server, Jira, CRM system)

In my upcoming project, I need to integrate a webapp with few other endpoints. Main duty of the webapp will be some kind of thin-client for inner JIRA system for company. Moreover, I'll need to ...
1
vote
1answer
414 views

JSP Include: one large bean or bean for each include

I want to refactor a webapp that consists of very distorted JSPs and servlets. Because we can't switch to a web framework easily we have to keep JSPs and Servlets, and now we are in doubt how to ...
1
vote
2answers
95 views

Can I use US-ASCII and UTF-8 encoding interchangeably for an XML file without a XML root declaration?

My source XML does NOT contain the root declaration i.e. <?xml version="1.0" encoding="utf-8" ?> And when I run the file command on it, I get: ASCII text, with very long lines, with CRLF ...
0
votes
1answer
96 views

calculating the average of a value over a month

I am working on a project right now that is having me calculate monthly interest on a bank account. The way the interest is supposed to be calculated is as follows: Use the daily average to calculate ...
0
votes
1answer
219 views

Separating UI from logic

I'm trying to develop a little game and for this I'd like to separate the UI from the game logic. So I'm thinking of using an "Animator" class that will be responsible for rendering the objects, but ...
4
votes
3answers
186 views

Batching immutable object changes?

With immutable models, what would be the best way to batch several changes? For example, let's have a Book that is immutable. I need to change both title and year. I could change one by one, but that ...
-1
votes
0answers
31 views

Moving from .net to Android - what is the best way for two apps I am developing? [on hold]

I have been developing with C# for a few years. I would love to go the Xamarin route but management have decided against that (too many java developers in the company) and I have to start learning ...
1
vote
2answers
224 views

When should I refactor a private class into a package-private class?

When I began implementing a class in my system (let's call it A), I realized I needed some kind of object that does something. So I needed a new class (let's call it B), but I made it a private static ...
0
votes
1answer
170 views

Did Java avoid multiple inheritance here?

I learnt that Java did not allow multiple inheritance using abstract classes for simplicity. In java, after a good design of class hierarchy, SubType would not get into trouble of same method ...
26
votes
8answers
52k views

Stack and Heap memory in Java

As I understand, in Java, stack memory holds primitives and method invocations and heap memory is used to store objects. Suppose I have a class class A { int a ; String b; ...
-2
votes
2answers
97 views

Java 8 vs Scala? Which one to learn? [on hold]

Scala has been promoted with advantages of perfect mix of functional programming and pure OOP and some more features which is difficult to achieve with java like reliable multi-thread programming. I ...
0
votes
1answer
137 views

Why does this evaluation function work in a connect four game in java

I am exploring how a Minimax algorithm can be used in a connect four game. I was looking through a program and found this evaluation function. private static int[][] evaluationTable = {{3, 4, 5, 7, ...
1
vote
1answer
214 views

From a DDD perspective is a report generating service a domain service or an infrastructure service?

Let assume we have the following service whose responsibility is to generate Excel reports: class ExcelReportService{ public String generateReport(String fileFormatFilePath, ResultSet data){ ...
-4
votes
1answer
76 views

Learning Java. Planning to create my first java project. I have an idea for a logfile error aggregator (details inside), but how do I start? [on hold]

I'm thinking of coding a 'Logfile Error Aggregator'. I'm not sure if it's anything useful or not, but it's something (possibly) practical: Assume there is a folder full of log files. Each file ...
0
votes
0answers
61 views

What is the best way to implement a workaround for Log4J's DailyRollingFileAppender issue on Windows?

I understand that there is an open bug with Log4J 1.2.x because (apparently) the java.io.File.renameTo() function fails due to a OS lock on the log file, which causes the file not to be renamed. I ...
-2
votes
0answers
26 views

Can Camel be used for building up html pages? [on hold]

Is it possible and furthermore should it be done? If I have 10 web services that all generate different parts of a web page. For example header, footer and body elements. Should I use Camel or some ...
4
votes
2answers
206 views

Using streams as method parameters and/or return types

So let's say I have a 'Transformer' interface that can transform one file-type to another. Let's say I also wish to use streams to provide the data to the Transformer. Which is the approach that is ...
1
vote
4answers
156 views

Java exception handling design

I am trying to design a simple exception handling strategy for web services middleware using some ideas from here: http://northconcepts.com/blog/2013/01/18/6-tips-to-improve-your-exception-handling/. ...
2
votes
2answers
128 views

Passing by value multiple times vs. Creating a public class variable

Suppose I have a series of methods across different classes that all use the same five core variables defined in my main method. I could chain these five variables as method arguments from one method ...
0
votes
1answer
383 views

HTTP Session: A single object or multiple?

I tested two approaches to store session data: The classic: 1 key, 1 object (And every key as static final String in a class) "user" --> UserObject "preferences" --> List ... An ...
0
votes
3answers
187 views

I want to understand clearly why can't we instantiate an object of an abstract class [duplicate]

Can I get a clear explanation why why can't we instantiate an object of an abstract class. I know abstract is not real. But I want to know more why can't we instantiate an object of an abstract class. ...
0
votes
4answers
548 views

Why 'List<E>' is an 'interface' but not 'abstract class'?

While defining the hierarchy, one can think to embed the abstract method(behaviour) in abstract class only because the derive concrete class posses that as core behaviour with it's specific ...
-1
votes
0answers
43 views

SCJP like book for C++ [closed]

I read SCJP study guide two years ago and it helped me become a better Java programmer. I would like to use the same success recipe, so I'm asking : Do you know any C++ book that is structured like ...
-2
votes
0answers
22 views

Not getting value in second cycle of when returning to form 1 from form 4 in java project [closed]

I am working on a java project, where i had created 4 jsp forms. On first form i had a select box. I select a value from option. Then I go to form 2,3 and 4,here the selected value is disabled. From ...
0
votes
3answers
193 views

Java 1.7 library with a Java 1.5 program - what are the options

I have a class library which is compiled with JDK 1.7 It uses several 1.7 features and classes and would be very difficult to get it recompiled in JDK 1.5. This needs to integrate with an old legacy ...
-2
votes
0answers
14 views

How to activate Code completion for Javafx CSS Tags? [closed]

I deactivated the Code suggestions and completion for Javafx specific CSS Tags like - fx-background-color accidentally in intellij idea. Anybody knows how to activate it again? Thanks
0
votes
1answer
354 views

What is the traditional way to maintain extensibility in a database-driven application like this?

I'm working on a simple application for a game in Java that allows a user to record whether they have collected a given item and how much experience it contains. This will work for multiple item types ...
4
votes
1answer
748 views

Attachment handling for web application with Jackrabbit

I need to manage attachments on my Spring web application and I thought to use an open source repository. My app it's a job approval system using J2EE / SPRING 3 Framework and Postgress DB to allow ...
1
vote
0answers
54 views

how to prevent mouse grab while debugging 3D application on a java IDE? [migrated]

Most 3D applications grab the mouse. This means the OS cursor is hidden and only the 3D application cursor is shown (and only within the application). In case it is a game, the cursor is completely ...
2
votes
1answer
359 views

Push-Based Events in a Services Oriented Architecture

I have come to a point, in building a services oriented architecture (on top of Thrift), that I need to expose events and allow listeners. My initial thought was, "create an EventService" to handle ...
270
votes
39answers
213k views

Why isn't Java used for modern web application development? [closed]

As a professional Java programmer, I've been trying to understand - why the hate toward Java for modern web applications? I've noticed a trend that out of modern day web startups, a relatively small ...
-1
votes
0answers
34 views

Making hard to hack java standalone apps [duplicate]

I created an app in java, but this app (packed as .jar) will be distributed to people, and I want to charge for usage of this app. I chose java as I'm unfamiliar with C++, to make a source code ...
1
vote
0answers
80 views

Streamlining a method to run faster [migrated]

Update: I did some guesswork tweaking and let the heap reach a maximum of ~450 Megabytes (was originally using invokeAll). The program just finished in 6.3 minutes. I've been advised to use ctrl + ...
-4
votes
0answers
47 views

Best Java Books To Buy? [closed]

I'm a beginner at programming and I'm currently using the book Heads First Java but I like to use 2-3 books when learning something new like this to make sure I cover everything and I have $60 US ...
-4
votes
0answers
37 views

not found symbol error for InitialContext in “final Context context =new InitialContext(jndiProperties)” [closed]

In Netbeans, when I am writing this particular code final Context context =new InitialContext(jndiProperties), then IntialContext showing error symbol not found. Here is Complete code: package ...
-5
votes
1answer
91 views

Help Understanding This? [closed]

I'm using the book Heads First Java and I just don't understand it at some parts and the book doesn't explain it well enough. Could someone please tell me what each line does? public class whileloop ...
2
votes
1answer
529 views

How to translate SQL query into REST API requests?

Let's say I have a machine-readable description (such as in WADL, Swagger or RAML) of a REST API that provides interface to a database. My users submit queries about underlying database in form of ...
-1
votes
0answers
51 views

How to start learning Java the right way? [closed]

I'm new in the world of programming! I don't know if my goal will be to develop windows programs, mobile apps, or web applications. I have heard that Java is a good language to tart learning coding ...
-1
votes
0answers
34 views

Is this way to implement ECIES cipher's correct? [migrated]

I downloaded source code of cryptosms from http://cryptosms.org/download.html and implemented ECIES cipher in my work for Java mobile. I doubt validity of this step (full code of my method is below): ...
11
votes
2answers
5k views

What happens if we serialize and deserialize two objects which references to each other?

To make it more clear, this is a quick example: class A implements Serializable { public B b; } class B implements Serializable { public A a; } A a = new A(); B b = new B(); a.b = b; b.a = a; So ...
-1
votes
0answers
78 views

How to properly close a Scanner class inside a method? [migrated]

I have this code that calls to a method in order to check if a number is a certain length, and if not, a new number should be reintroduced by the user. Problem here is, I can't find the proper way ...
0
votes
0answers
4 views

working with the command prompt in Java [migrated]

I've been learning java on my own and I've come to a point where I need to pass arguments from the command prompt. I had previously been using Netbeans, which has become a bit of a crutch, but I want ...
1
vote
2answers
497 views

docker-izing a classical db-based webapp - single or multiple containers?

I have a classic Java webapp. It is composed of a database (PostgreSQL), a servlet container (Tomcat) and my code (deployed on Tomcat as a *.war file). I want to package/deploy it using Docker ...
3
votes
1answer
62 views

Skeletal/Abstract class just to store shared state?

Given an interface for the Strategy pattern like so: public interface Strategy { public Output execute(Input input); public Output getLastExecutionOutput(); } if I want to store the last ...
1
vote
0answers
94 views

Is there a quicker method for returning a sublist after a certain index of a list in Java? [migrated]

I'm working on a program in which I will need to frequently truncate the beginning of a list, by just a few indices. (Sometimes, only one.) Then, the new list must be passed on to another method, ...
1
vote
1answer
180 views

How to migrate an XML serialization framework in Java in a tightly coupled system?

I work for a company that uses XML for storing a bunch of serialized Java classes. The framework we use is Apache Betwixt (abandonded in 2008) and it's kind of pain to maintain and extend (it seemed ...
-4
votes
0answers
35 views

How to get requestet domain? [closed]

I am trying to make a selector based on the domain. I want to host a lot of servers behind one public ip. I created a java program that forwards everything to the server or vice versa something back ...
-5
votes
1answer
93 views

What is the purpose of Deprecation? [closed]

Is it just giving different names to previously named method? Does it change with the language you use? Is it essential? I have noticed different APIs having deprecated methods, which actually seem ...