Most viewed questions in Java

+8 votes
11 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
149,361 views
+15 votes
18 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
• 700 points
104,203 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
87,375 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
70,406 views
+9 votes
12 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,560 points
57,683 views
+1 vote
11 answers

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

you mysql server instance is not running ...READ MORE

Jun 15, 2019 in Java by Encrypter Manyange
38,600 views
+2 votes
10 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
36,649 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
33,252 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 30,988 views
0 votes
10 answers

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

The best way is to add the ...READ MORE

Dec 10, 2018 in Java by Nabarupa
29,672 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
25,041 views
0 votes
10 answers

Java - sending HTTP parameters via POST method easily

I personally use Apache's HTTPClient/HttpCore libraries to do ...READ MORE

Dec 10, 2018 in Java by robocop
19,093 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,880 points
14,953 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,880 points
13,084 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
12,888 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,400 points

edited Nov 6, 2018 by Omkar 12,829 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
11,472 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,490 points
11,262 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,560 points
9,957 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,880 points
9,922 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,490 points
9,069 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
8,890 views
0 votes
2 answers

How to clear the console in Java?

import java.io.IOException; public class CLS { ...READ MORE

Aug 27, 2018 in Java by Sushmita
• 6,880 points
8,559 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
7,942 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,660 points
7,933 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 parth295
• 4,640 points
7,338 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
7,181 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,150 points
7,118 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,660 points
7,005 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
6,711 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
6,484 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,560 points
6,475 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,080 points
6,465 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,600 points
6,288 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
5,715 views
+1 vote
2 answers

Non-static variable cannot be referenced from a static context. Explain?

class Program { int count ...READ MORE

Sep 27, 2019 in Java by anonymous
5,642 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
5,593 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,080 points
5,575 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
• 45,310 points
5,541 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,880 points
5,521 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
4,702 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,880 points
4,315 views
0 votes
1 answer

How do i create generic array in Java

Generic array creation is not allowed in Java. But, ...READ MORE

May 15, 2018 in Java by parth295
• 4,640 points
4,238 views
+2 votes
10 answers

Convert Java Byte Array - String - Byte Array

Character Stream Vs Byte Stream Character oriented are ...READ MORE

Sep 25, 2018 in Java by carldivin
• 180 points
4,029 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,880 points
3,930 views
0 votes
1 answer

What causes java.lang.reflect.InvocationTargetException

The exception is thrown if InvocationTargetException - if ...READ MORE

Jun 19, 2018 in Java by Rishabh
• 3,560 points
3,789 views
0 votes
1 answer

DTO vs VO vs POJO vs JavaBeans

Data Transfer Object is used for transferring a collection ...READ MORE

Aug 14, 2018 in Java by code.reaper12
• 3,470 points
3,692 views
0 votes
2 answers

Include all the jars in a directory within the Java classpath

Just use lib/*   not lib/*.jar   That's the ...READ MORE

Apr 6, 2019 in Java by anonymous
3,655 views
+2 votes
1 answer

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
• 45,310 points
3,391 views
0 votes
1 answer

How to refresh a JTable model after insert delete or update the data

In my opinion, you can notify your ...READ MORE

Oct 10, 2018 in Java by code.reaper12
• 3,470 points
3,347 views