Most viewed questions in Java

+9 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
187,752 views
+15 votes
19 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
131,731 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
110,785 views
+9 votes
13 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
95,088 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
89,212 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
53,319 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
52,653 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
48,685 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 41,334 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
39,047 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
34,854 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
27,199 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
18,843 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 17,205 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
16,482 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
15,947 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
15,670 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
15,303 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
12,881 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,530 points
12,727 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,530 points
12,693 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
12,530 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
12,385 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
11,734 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,890 points
11,105 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
10,757 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,640 points
10,446 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
10,347 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
9,650 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
• 50,480 points
8,933 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,090 points
8,618 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,610 points
8,539 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
• 50,480 points
8,159 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
7,895 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,876 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
7,773 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
7,594 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
7,484 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
7,312 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,090 points
7,229 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
6,992 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
6,541 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
6,525 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
6,254 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
6,169 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
5,717 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
5,048 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,796 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,580 points
4,762 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
4,677 views