Questions tagged [java]

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.

Initial help

Before asking a question, use the search box in the upper right corner to see if it has been asked before by others (we have many duplicates), and please read Writing the perfect question to learn how to get Jon Skeet to answer your question.


Background

Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems and released in 1995. Java is currently owned by Oracle, which purchased Sun in 2010.

Very few computers can run Java programs directly. Therefore the Java environment is normally made available by installing a suitable software component. For Windows computers, this is usually done by downloading the free Java Runtime Environment (JRE) from Oracle which allows the system to run Java programs. The easiest way to do this is from java.com.

Developers frequently need additional tools which are available in the free Java Development Kit (JDK) alternative to the JRE, which for Windows must be downloaded from Oracle and installed manually.

Note: Other vendors exist but usually have license fees. For Linux and other platforms consult the operating system documentation.

Most of the Java platform has been open sourced. The open source Java project is called OpenJDK. All major components of the platform are in open source, including the JVM (Java Virtual Machine), the Java compiler, and the class libraries.

More information:

Hello World

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}

Java source code is compiled to an intermediate form (bytecode instructions for the JVM) that can be executed with the java command.

Beginners resources

  • The Java Tutorials - Starts from scratch on Windows/Linux/Mac and covers most of the standard library.

Day to day resources

Advanced resources

Free Online Resources

4885 questions
390
votes
35 answers

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

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 percentage of them appears to be using Java…
Cliff
  • 590
  • 3
  • 6
  • 12
295
votes
16 answers

Grokking Java culture - why are things so heavy? What does it optimize for?

I used to code in Python a lot. Now, for work reasons, I code in Java. The projects I do are rather small, and possibly Python would work better, but there are valid non-engineering reasons to use Java (I can't go into details). Java syntax is no…
Mikhail Ramendik
  • 1,549
  • 2
  • 9
  • 11
293
votes
14 answers

How do you unit test private methods?

I am working on a java project. I am new to unit testing. What is the best way to unit test private methods in java classes?
Vinoth Kumar C M
  • 15,455
  • 23
  • 57
  • 86
282
votes
6 answers

Choosing between Single or multiple projects in a git repository?

In a git environment, where we have modularized most projects, we're facing the one project per repository or multiple projects per repository design issue. Let's consider a modularized project: myProject/ +-- gui +-- core +-- api +--…
Johan Sjöberg
  • 3,007
  • 4
  • 16
  • 7
275
votes
14 answers

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat the purpose of object oriented programming. If we…
Slamice
  • 2,647
  • 3
  • 14
  • 10
262
votes
7 answers

What does the Spring framework do? Should I use it? Why or why not?

So, I'm starting a brand-new project in Java, and am considering using Spring. Why am I considering Spring? Because lots of people tell me I should use Spring! Seriously, any time I've tried to get people to explain what exactly Spring is or what…
sangfroid
  • 3,219
  • 4
  • 17
  • 12
219
votes
6 answers

What exactly makes the Haskell type system so revered (vs say, Java)?

I'm starting to learn Haskell. I'm very new to it, and I am just reading through a couple of the online books to get my head around its basic constructs. One of the 'memes' that people familiar with it have often talked about, is the whole "if it…
phatmanace
  • 2,445
  • 3
  • 14
  • 11
201
votes
13 answers

When are Getters and Setters Justified?

Getters and setters are often criticized as being not proper OO. On the other hand, most OO code I've seen has extensive getters and setters. When are getters and setters justified? Do you try to avoid using them? Are they overused in general? If…
Winston Ewert
  • 24,732
  • 12
  • 72
  • 103
198
votes
40 answers

My Dad is impatient with the pace of my learning to program. What do I do?

So my Dad bought me 5 books on programming (C++, Java, PHP, Javascript, Android) about a month ago. He's an architect and he knows NOTHING about programming. He bought me them because I told him programming was fun and I wanted to learn it. As you…
David
  • 461
  • 2
  • 6
  • 11
179
votes
6 answers

What is the point of using DTO (Data Transfer Objects)?

What is the point of using DTO and is it an out dated concept? I use POJOs in the view layer to transfer and persist data. Can these POJOs be considered as an alternative to DTOs?
Vinoth Kumar C M
  • 15,455
  • 23
  • 57
  • 86
170
votes
10 answers

Mono is frequently used to say "Yes, .NET is cross-platform". How valid is that claim?

In What would you choose for your project between .NET and Java at this point in time? I say that I would consider the "Will you always deploy to Windows?" the single most important technical decision to make up front in a new web project, and if…
user1249
147
votes
15 answers

Why did memory-managed languages like Java, Javascript, and C# retain the `new` keyword?

The new keyword in languages like Java, Javascript, and C# creates a new instance of a class. This syntax seems to have been inherited from C++, where new is used specifically to allocate a new instance of a class on the heap, and return a pointer…
Channel72
  • 2,475
  • 5
  • 27
  • 28
145
votes
6 answers

What is the point of having every service class have an interface?

At the company I work at, every service class has a corresponding interface. Is this necessary? Notes: Most of these interfaces are only used by a single class We are not creating any sort of public API With modern mocking libraries able to…
Bob Roberts
  • 1,777
  • 2
  • 11
  • 12
142
votes
2 answers

What is a "shaded" Java dependency?

JVM developer here. Lately I've seen banter on IRC chat rooms and even in my own office about so-called "shaded" Java libraries. The context of the use will be something like: "Such and so provides a "shaded" client for XYZ." Perfect example is…
smeeb
  • 4,820
  • 10
  • 30
  • 49
140
votes
7 answers

Why doesn't Java 8 include immutable collections?

The Java team has done a ton of great work removing barriers to functional programming in Java 8. In particular, the changes to the java.util Collections do a great job of chaining transformations into very fast streamed operations. Considering…
GlenPeterson
  • 14,890
  • 6
  • 47
  • 75
1
2 3
99 100