Trending questions in Java

0 votes
1 answer

Serializing a lambda

With the release of Java 8, Oracle introduced the ...READ MORE

Nov 16, 2018 in Java by code.reaper12
• 3,500 points
853 views
0 votes
1 answer

Java Timer vs Executor Service

According to Java Concurrency in Practice: Timer is ...READ MORE

Jul 26, 2018 in Java by code.reaper12
• 3,500 points
5,691 views
0 votes
1 answer

How to force garbage collection in Java?

Your best option is to call System.gc() which simply ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
837 views
0 votes
1 answer

How can we handle the javax.net.ssl.SSLHandshakeException?

import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import java.io.OutputStream; // ...READ MORE

Oct 10, 2018 in Java by Daisy
• 8,120 points
2,379 views
0 votes
1 answer

Find Oracle JDBC driver in Maven repository

Download the jar and place it in ...READ MORE

Sep 26, 2018 in Java by Daisy
• 8,120 points
2,982 views
0 votes
1 answer

ArrayIndexOutOfBoundsException in Java

The index of array starts from 0. public ...READ MORE

Nov 23, 2018 in Java by Namitha
475 views
0 votes
1 answer

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: How to handle this exception?

You have a com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure java.net.ConnectException: ...READ MORE

Oct 8, 2018 in Java by Parth
• 4,630 points
2,421 views
0 votes
1 answer

Affinity in Java thread

Well, as far as I know, I ...READ MORE

Oct 31, 2018 in Java by code.reaper12
• 3,500 points
1,434 views
0 votes
1 answer

Running Java program without main method.

This would have worked fine till Java ...READ MORE

Nov 21, 2018 in Java by Anoop
477 views
0 votes
1 answer

What is Enum in Java?

 It means that the type argument for ...READ MORE

Nov 13, 2018 in Java by Frankie
• 9,830 points
636 views
0 votes
1 answer

How to convert or cast hashmap to JSON object in Java, and again convert JSON object to JSON string?

You can use: new JSONObject(map); READ MORE

Jun 27, 2018 in Java by Akrati
• 3,190 points
6,595 views
0 votes
1 answer

@RequestMapping annotation in Java Spring

The @RequestMapping annotation in Spring Framework is ...READ MORE

Sep 12, 2018 in Java by code.reaper12
• 3,500 points
3,291 views
0 votes
1 answer

Which is the standard concise way to copy a file in Java?

As toolkit mentions above, Apache Commons IO ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
438 views
0 votes
2 answers

Connection reset : java.net.SocketException

You should check whether the client program is ...READ MORE

Sep 6, 2018 in Java by Sushmita
• 6,910 points
5,561 views
0 votes
1 answer

Writing a UTF-8 file with Java

You can make use of a FileOutputStream rather than ...READ MORE

Oct 15, 2018 in Java by anto.trigg4
• 3,440 points
1,739 views
0 votes
1 answer

Why do we use threads in Java?

Reasons for using Multithreading in Java: When a ...READ MORE

Nov 2, 2018 in Java by nsv999
• 5,500 points
934 views
0 votes
1 answer

How can we encrypt a String in Java?

Let's assume the bytes to encrypt are ...READ MORE

Oct 26, 2018 in Java by Sushmita
• 6,910 points
1,223 views
0 votes
2 answers

How to parse a date?

SimpleDateFormat parser=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz ...READ MORE

Dec 6, 2018 in Java by Sushmita
• 6,910 points
653 views
0 votes
1 answer

Array indexOf() in Java

You can use this indexOf() method through Arrays utility class. If the ...READ MORE

Sep 20, 2018 in Java by geek.erkami
• 2,680 points
2,681 views
0 votes
2 answers

How to initialize multi-dimensional array in java?

a multidimensional array can define an array ...READ MORE

Mar 18, 2019 in Java by monica jesvina
991 views
0 votes
1 answer

org.xml.sax.SAXParseException: How to handle this exception?

This is often caused by a white ...READ MORE

Jul 9, 2018 in Java by sharth
• 3,370 points
5,731 views
0 votes
1 answer

Default Object.toString() in hashcode

Well, the hash code object is the ...READ MORE

Oct 31, 2018 in Java by code.reaper12
• 3,500 points
767 views
0 votes
1 answer

varargs in Java

Well, varargs are generally used to deal ...READ MORE

Oct 31, 2018 in Java by code.reaper12
• 3,500 points
621 views
0 votes
1 answer

Can't access static fields in inner classes in Java

Well, the major idea behind this concept ...READ MORE

Oct 9, 2018 in Java by anto.trigg4
• 3,440 points
1,583 views
0 votes
1 answer

How to run a JAR file in Java?

The command given below will help you ...READ MORE

Jun 1, 2018 in Java by Parth
• 4,630 points
7,172 views
0 votes
1 answer

How can we return a JSON object from a Java Servlet?

response.setContentType("application/json"); // Get the printwriter object from response ...READ MORE

Jul 6, 2018 in Java by sharth
• 3,370 points
5,648 views
0 votes
1 answer

doGet and doPost in Servlets

When you are using HTTP GET requests ...READ MORE

Jul 17, 2018 in Java by Mrunal
• 680 points
5,135 views
+1 vote
2 answers

What are inner classes and static nested classes?

Nested classes are divided into two categories: ...READ MORE

Dec 3, 2018 in Java by Sushmita
• 6,910 points
3,653 views
0 votes
1 answer

Working of Progress Bar for a File Download

Once of the ways to achieve is ...READ MORE

Jun 26, 2018 in Java by Rishabh
• 3,620 points
6,013 views
0 votes
1 answer

Remote debugging a Java application

I noticed that some people are cutting ...READ MORE

Oct 16, 2018 in Java by Sushmita
• 6,910 points
1,138 views
0 votes
1 answer

Error - trustAnchors parameter must be non-empty

This bizarre message means that the truststore ...READ MORE

Oct 29, 2018 in Java by Daisy
• 8,120 points
572 views
0 votes
1 answer

Java String interning

The String.intern() method of Java Strings ensures ...READ MORE

Oct 25, 2018 in Java by geek.erkami
• 2,680 points
688 views
0 votes
1 answer

HTML Parsing in Java

Well, to parse HTML I used JTidy.  Basically, ...READ MORE

Nov 2, 2018 in Java by geek.erkami
• 2,680 points
338 views
0 votes
1 answer

Why “non-static method cannot be referenced from a static context”?

You can't call something that doesn't exist. ...READ MORE

Oct 17, 2018 in Java by sharth
• 3,370 points
1,014 views
0 votes
1 answer

Executing commands with parameters in Java

Try using the below command: Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", ...READ MORE

Sep 5, 2018 in Java by geek.erkami
• 2,680 points
2,731 views
0 votes
1 answer

Constructor injection vs Setter injection in Spring Framework

Here, I have listed down few differences. ...READ MORE

Aug 30, 2018 in Java by anto.trigg4
• 3,440 points
2,999 views
0 votes
1 answer

Optional return type of getter() in Java 8

Well, you can do that but originally ...READ MORE

Oct 23, 2018 in Java by code.reaper12
• 3,500 points
583 views
0 votes
1 answer

Usage of abstract class and interface

Well let me draw a clear line ...READ MORE

Oct 23, 2018 in Java by geek.erkami
• 2,680 points
560 views
+1 vote
1 answer

Converting a date string to a DateTime object using Joda Time library

Use DateTimeFormat: DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss"); DateTime dt = ...READ MORE

Jul 24, 2018 in Java by scarlett
• 1,290 points
4,467 views
0 votes
1 answer

How to convert a string representation of a hex dump to a byte array using Java?

public static byte[] hexStringToByteArray(String s) { ...READ MORE

Sep 26, 2018 in Java by sharth
• 3,370 points
1,693 views
0 votes
1 answer

How to download a file from spring controllers?

@RequestMapping(value = "/files/{file_name}", method = RequestMethod.GET) public void ...READ MORE

Sep 4, 2018 in Java by code.reaper12
• 3,500 points
2,629 views
0 votes
1 answer

Bean life cycle in Spring Bean Factory Container

Bean life cycle in Spring Bean Factory ...READ MORE

Aug 30, 2018 in Java by code.reaper12
• 3,500 points
2,869 views
0 votes
1 answer

Static methods can't be abstract in Java

Well, Java doesn't allow this because of ...READ MORE

Oct 12, 2018 in Java by v.liyyah
• 1,300 points
887 views
+1 vote
2 answers

Can I convert my Java program to an .exe file?

Launch4j is a cross-platform tool for wrapping ...READ MORE

Oct 18, 2018 in Java by Sushmita
• 6,910 points
3,436 views
0 votes
1 answer

notify() vs. notifyAll() in Java

notify() is used to wake any thread in the wait ...READ MORE

Sep 20, 2018 in Java by code.reaper12
• 3,500 points
1,787 views
0 votes
1 answer

Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved

Check the maven repository server is up. Check ...READ MORE

Jun 25, 2018 in Java by Sushmita
• 6,910 points
5,548 views
0 votes
2 answers

How to find out a single character appears in String or not in Java?

You can use string.indexOf('s'). If the 's' is present in string, ...READ MORE

Aug 7, 2018 in Java by Sushmita
• 6,910 points
5,157 views
0 votes
1 answer

Number of Characters in Java String

I think you can make use of ...READ MORE

Oct 23, 2018 in Java by anto.trigg4
• 3,440 points
350 views
0 votes
1 answer

Recursively delete directories in Java

You can try using the FileUtils class of Apache's commons-io: FileUtils.deleteDirectory(new ...READ MORE

Oct 23, 2018 in Java by code.reaper12
• 3,500 points
342 views
0 votes
5 answers

How to compare Strings in Java?

String fooString1 = new String("foo"); String fooString2 = ...READ MORE

Jul 12, 2018 in Java by Daisy
• 8,120 points
2,189 views