Most viewed questions in Java

+11 votes
12 answers

Default parameters of XMS and XMX in JVM

You use these Java command-line parameters to ...READ MORE

Nov 13, 2018 in Java by Murali
254,961 views
+8 votes
14 answers

Unable to resolve this error: "javac is not recognized as an internal or external command"

Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and ...READ MORE

May 23, 2018 in Java by Rishabh
• 3,580 points
196,048 views
+15 votes
22 answers

How can I convert String to JSON object in Java?

Hi @Daisy You can use Google gson  for more ...READ MORE

Feb 7, 2019 in Java by Suresh
• 720 points
186,883 views
+2 votes
10 answers

How to import a jar file in Eclipse?

To import jar file in your Eclipse ...READ MORE

May 15, 2018 in Java by sharth
• 3,370 points
163,291 views
+2 votes
12 answers

“A Non-static method cannot be referenced from a static context” error

this method must be static so that it will exist even though the ...READ MORE

Jun 11, 2019 in Java by Neha
• 330 points
135,968 views
+2 votes
11 answers

Unable to execute jar- file: “no main manifest attribute”

add a jar/manifest/attributes setting like this: apply plugin: ...READ MORE

Nov 27, 2018 in Java by krishti
93,861 views
+1 vote
11 answers

How does java.net.SocketException: Connection reset happen ?

You can use wireshark to view the ...READ MORE

Dec 7, 2018 in Java by tushh
82,874 views
+1 vote
12 answers

Communications link failure: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

I had the same problem.then i did ...READ MORE

Aug 15 in Java by Bhuvana
79,156 views
+1 vote
11 answers

How to send HTTP POST requests on Java?

How to invoke Thread dump analysis API? Invoking ...READ MORE

Jun 16, 2019 in Java by Jim
• 810 points

reshown Jun 17, 2019 by Vardhan 69,489 views
0 votes
11 answers

What is the correct way to add external Jars to IntelliJ IDEA Project?

You can also create a "lib" folder ...READ MORE

Jul 17 in Java by Zeenu
66,573 views
+1 vote
10 answers

Iterate over a JSONObject?

You can use the following method to ...READ MORE

Dec 7, 2018 in Java by Shuvodip
54,843 views
0 votes
11 answers

Java - sending HTTP parameters via POST method easily

You can write like this simply get ...READ MORE

Jul 7 in Java by anonymous
• 140 points
51,258 views
0 votes
3 answers

How can I separate the digits of an int number in Java?

import java.util.*; public class AmstrongNumber { public static void ...READ MORE

Aug 6, 2019 in Java by anonymous
36,598 views
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 6, 2018 by Omkar 29,767 views
0 votes
1 answer

HttpServletRequest get JSON POST data

Normally you can GET and POST parameters ...READ MORE

Nov 29, 2018 in Java by Sushmita
• 6,890 points
28,397 views
0 votes
2 answers

“Cannot find symbol” compilation error

The "Cannot find symbol" errors generally occur when you ...READ MORE

Apr 3, 2019 in Java by patricblues
• 140 points
25,444 views
0 votes
4 answers

How can we define global variables in java?

class G { static String globalVar ...READ MORE

Jan 29, 2019 in Java by zemiak
23,343 views
+1 vote
10 answers

How to make mock to void methods with mockito

You can use partial mocking to serve ...READ MORE

Dec 7, 2018 in Java by nitesh
23,176 views
0 votes
2 answers

Resolving PKIX path building failed Error?

You need to add the certificate for App2 to ...READ MORE

Sep 24, 2018 in Java by Sushmita
• 6,890 points
21,549 views
+1 vote
10 answers

Hibernate hbm2ddl.auto possible values and their uses

hibernate.hbm2ddl.auto (e.g. none (default value), create-only, drop, create, create-drop, validate, and update) Setting to perform SchemaManagementTool actions automatically as ...READ MORE

Dec 7, 2018 in Java by Shuvodip
21,002 views
+1 vote
2 answers

How to take multiple integer input in one line using BufferedReader in Java?

Try this in case you don't know ...READ MORE

Aug 29, 2019 in Java by Sirajul
• 57,870 points
20,720 views
+1 vote
1 answer

3 dot in parameter in Java

The "Three Dots" in java is called ...READ MORE

Nov 21, 2018 in Java by geek.erkami
• 2,680 points
20,374 views
+2 votes
2 answers

Javac command not working in my windows 10

Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and ...READ MORE

Aug 6, 2019 in Java by Sirajul
• 57,870 points
20,133 views
+1 vote
4 answers

What is difference between access modifier and access specifier in java

Access Specifier:- This can be understood as ...READ MORE

Feb 14, 2019 in Java by Priyaj
• 57,640 points
18,988 views
0 votes
1 answer

How can I get the current date and time in UTC or GMT in Java?

This definitely returns UTC time: as String ...READ MORE

Jun 7, 2018 in Java by Rishabh
• 3,580 points
18,274 views
0 votes
1 answer

How to find the nth prime number in Java?

Here is the code to find nth ...READ MORE

Mar 4, 2019 in Java by Priyaj
• 57,640 points
17,871 views
+1 vote
3 answers

How to take input using BufferedReader in Java?

yupp i am explaining every thing .. We ...READ MORE

Feb 1 in Java by Rohan
• 180 points
17,858 views
0 votes
1 answer

GSON throwing “Expected BEGIN_OBJECT but was BEGIN_ARRAY”?

This will work: ChannelSearchEnum[] enums = gson.fromJson(yourJson, ChannelSearchEnum[].class); But ...READ MORE

Dec 26, 2018 in Java by Sushmita
• 6,890 points
17,568 views
0 votes
1 answer

Setting time zone of a java.util.Date

You can make use of the following ...READ MORE

Aug 14, 2018 in Java by anto.trigg4
• 3,440 points
16,968 views
0 votes
1 answer

object references an unsaved transient instance - save the transient instance before flushing

You should add cascade="all" (if using xml) ...READ MORE

Sep 26, 2018 in Java by Parth
• 4,630 points
16,855 views
0 votes
3 answers

How to clear the console in Java?

import java.io.IOException; public class chkClearScreen {     public static void ...READ MORE

Aug 26 in Java by ItsJustRaja
16,749 views
+2 votes
2 answers

Using while loop i want to print 10 even numbers

public class Loops { ...READ MORE

Dec 4, 2019 in Java by One of the Simplest ways to answer you q
15,390 views
0 votes
1 answer

How to refresh data in ViewPager Fragment ?

Using the ViewPager.OnPageChangeListener is the correct way to go, ...READ MORE

Mar 6, 2019 in Java by developer_1
• 3,300 points
14,275 views
0 votes
1 answer

Java execute vs executeQuery vs executeUpdate

I think the major differences between execute, executeQuery, ...READ MORE

Jul 30, 2018 in Java by geek.erkami
• 2,680 points
14,261 views
0 votes
1 answer

How can I solve this: To prevent a memory leak, the JDBC Driver has been forcibly unregistered

What can you do? Ignore these warnings. Tomcat ...READ MORE

Jan 8, 2019 in Java by Daisy
• 8,110 points
12,810 views
+1 vote
1 answer

Setting selected item of Spinner by value rather than by position

Suppose your Spinner is named newSpinner, and it contains ...READ MORE

Aug 10, 2018 in Java by 93.lynn
• 1,620 points
12,497 views
+1 vote
1 answer

What is a simple way to repeat a string in java?

From Java 11 on, there's a method String::repeat that does ...READ MORE

Aug 28, 2018 in Java by Frankie
• 9,810 points
12,420 views
0 votes
1 answer

"No mapping found for HTTP request with URI[....] in DispatherServlet"

Your standard Spring MVC application will serve ...READ MORE

Jun 6, 2018 in Java by prasad
• 160 points
11,278 views
0 votes
1 answer

Why is my Spring @Autowired field null?

If you are not coding a web ...READ MORE

Dec 27, 2018 in Java by Daisy
• 8,110 points
10,754 views
0 votes
2 answers

What is the difference between Map and HashMap in java?

The basic difference is : Map is ...READ MORE

Aug 28, 2019 in Java by Sirajul
• 57,870 points
10,718 views
0 votes
2 answers

What is the difference between string object and string literal?

A String literal is a Java language concept. This ...READ MORE

Aug 16, 2019 in Java by Sirajul
• 57,870 points
10,490 views
0 votes
1 answer

How to set Encoding in Java ?

Unfortunately, the file.encoding property has to be specified as ...READ MORE

May 29, 2018 in Java by Rishabh
• 3,580 points
10,439 views
0 votes
1 answer

Autowired field pointing NULL in Spring

The field annotated @Autowired is null because ...READ MORE

Jun 6, 2018 in Java by avi
• 160 points
10,239 views
0 votes
1 answer

Unable to find valid certification path to requested target

The problem appears when your server has ...READ MORE

Dec 12, 2018 in Java by Daisy
• 8,110 points
10,214 views
0 votes
1 answer

What's the difference between @JoinColumn and mappedBy when using a JPA @OneToMany association?

The annotation @JoinColumn indicates that this entity is the owner of ...READ MORE

Oct 18, 2018 in Java by Sushmita
• 6,890 points
10,081 views
0 votes
2 answers

How do I read and convert an InputStream object to string type?

You can also use Java Standard Library ...READ MORE

Jul 17, 2018 in Java by Sushmita
• 6,890 points
9,928 views
0 votes
2 answers

how can we Create instance for generic type in java

private static class SomeContainer<E> { ...READ MORE

Aug 27, 2018 in Java by Sushmita
• 6,890 points
9,690 views
0 votes
2 answers

How do i create generic array in Java

as first tip you cannot assign value ...READ MORE

Feb 12 in Java by sama
9,471 views
0 votes
1 answer

Static Map initialization in Java

I would suggest you to use the ...READ MORE

May 4, 2018 in Java by Akrati
• 3,170 points
9,089 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look to this example: https://github.com/burningwave/co ...READ MORE

Dec 20, 2019 in Java by Roberto
• 370 points

edited Jul 6 by Roberto 8,955 views