Most viewed questions in Java

0 votes
1 answer

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK

In your Eclipse IDE, go into Window > Preferences > Java > Installed JREs > ...READ MORE

Jun 18, 2018 in Java by Parth
• 4,630 points
3,020 views
0 votes
0 answers

Server Tomcat v9.0 Server at localhost failed to start

I am using Tomcat server v9.0 but ...READ MORE

May 23, 2022 in Java by Kichu
• 19,050 points
3,009 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,990 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,969 views
+1 vote
1 answer

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

This error means you're trying to load ...READ MORE

Jun 8, 2018 in Java by Rishabh
• 3,620 points
2,947 views
0 votes
1 answer

How can we run eclipse in clean mode? and what will happen if we do so?

if set to "true", any cached data ...READ MORE

Jan 11, 2019 in Java by Daisy
• 8,120 points
2,940 views
0 votes
1 answer

Start a Standalone Application in Java

You can make this work by calling start(...) directly on a ...READ MORE

Mar 6, 2019 in Java by developer_1
• 3,320 points
2,934 views
0 votes
1 answer

JavaScript: Upload file

For a Pure JS, you can use ...READ MORE

Feb 18, 2022 in Java by Aditya
• 7,680 points
2,893 views
0 votes
1 answer

Getting error 404 not found when trying to download JDK

Try this command, it should work: wget --no-check-certificate ...READ MORE

Dec 26, 2018 in Java by Omkar
• 69,210 points
2,890 views
0 votes
1 answer

How to encode the HTTP URL address in Java?

Use one of the constructors with more ...READ MORE

Oct 23, 2018 in Java by Sushmita
• 6,910 points
2,889 views
0 votes
1 answer

System.currentTimeMillis vs System.nanoTime

In case you want extremely precise measurements ...READ MORE

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

What is the need to override the equals and hashCode methods in Java?

You must override hashCode() in every class ...READ MORE

Jan 2, 2019 in Java by Daisy
• 8,120 points
2,877 views
0 votes
0 answers

how to send a pdf file as a response to frontend?

when a user upload a file to ...READ MORE

Apr 11, 2020 in Java by Abhishek
• 120 points
2,876 views
0 votes
0 answers

resource : Invocation of init method failed

I am getting this error when I ...READ MORE

May 16, 2022 in Java by Kichu
• 19,050 points
2,868 views
0 votes
2 answers

How can I convert an 'ArrayList<String> to 'String[]' in Java

In Java 8 or later: String listString = ...READ MORE

Aug 20, 2019 in Java by Sirajul
• 59,230 points
2,866 views
0 votes
1 answer

Convert Milliseconds to “X mins, x seconds” in Java?

I wrote a function which converts milliseconds ...READ MORE

May 30, 2018 in Java by Rishabh
• 3,620 points
2,862 views
0 votes
2 answers

How to left pad a string with zero in java?

String paddedString = org.apache.commons.lang.StringUtils.leftPad("129018", 10, "0") the second ...READ MORE

Aug 31, 2018 in Java by Sushmita
• 6,910 points
2,859 views
0 votes
1 answer

What is Classpath in java?

Classpath is a parameter in the Java virtual machine or ...READ MORE

Jun 5, 2018 in Java by Daisy
• 8,120 points
2,855 views
0 votes
1 answer

Error: setOnItemClickListener cannot be used with a spinner

Hello @kartik, See the first line of your ...READ MORE

Jun 1, 2020 in Java by Niroj
• 82,880 points
2,847 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,843 views
0 votes
3 answers

Change date format in a Java string

The reason for the inaccuracy is because ...READ MORE

Feb 9, 2022 in Java by Soham
• 9,700 points
2,832 views
0 votes
1 answer

Convert comma-separated String to ArrayList?

List<String> alist = Arrays.asList(str.split("\\s*,\\s*")); The above code splits ...READ MORE

May 17, 2018 in Java by sharth
• 3,370 points
2,803 views
0 votes
2 answers

How to check if a string has only letters

You could probably use Java 8 lambda ...READ MORE

Aug 30, 2019 in Java by Karan
• 19,610 points
2,778 views
0 votes
2 answers

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

Check out the answer here https://stackoverflow.com/a/61372736/7747942 READ MORE

Apr 23, 2020 in Java by Anonymous
2,775 views
0 votes
0 answers

Sending request using json object return 404 error code

I am getting mad with this code ...READ MORE

Jun 19, 2019 in Java by FooBayo
• 120 points

edited Jun 19, 2019 by FooBayo 2,760 views
+1 vote
0 answers

I am getting below error "The method readerFor(Class<Map>) is undefined for the type CsvMapper"

I Have requirement to convert csv to ...READ MORE

Dec 29, 2019 in Java by anonymous
• 160 points
2,758 views
0 votes
2 answers

How to sort an ArrayList of custom object by property in Java?

You can Sort using java 8 yourList.sort(Comparator.comparing(Classname::getName)); or  yourList.stream().forEach(a -> ...READ MORE

Aug 14, 2018 in Java by samarth295
• 2,220 points
2,737 views
0 votes
1 answer

Following error is occurring "Can't start Eclipse - Java was started but returned exit code=13"

There are combinations of Operating System, JDK ...READ MORE

Apr 19, 2018 in Java by Rishabh
• 3,620 points
2,729 views
0 votes
1 answer

How does omitting curly braces in Java program, effect the code ?

Using braces makes the code more maintainable ...READ MORE

May 14, 2018 in Java by Rishabh
• 3,620 points
2,716 views
0 votes
1 answer

How can we get file extension in Java?

To get the file extension, we can ...READ MORE

May 8, 2018 in Java by Parth
• 4,630 points
2,716 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,712 views
0 votes
1 answer

How to add row in JTable

To create a table: JTable table = new ...READ MORE

Jun 29, 2018 in Java by Akrati
• 960 points
2,711 views
0 votes
1 answer

Java and MySql: Check if database exists

You can get the list of databases ...READ MORE

Sep 30, 2019 in Java by Tina
2,699 views
0 votes
4 answers

Remove extra spaces from string in java

import java.util.regex.Matcher; import java.util.regex.Pattern; String pattern="[\\s]"; String replace=""; part="name=john age=13 year=2001"; Pattern ...READ MORE

Sep 10, 2018 in Java by Parth
• 4,630 points
2,687 views
0 votes
0 answers

How to set XML Attribute inside XML Element in Java Pojo Class - JAVX

How can I get this Output Response? <Response> ...READ MORE

Apr 19, 2022 in Java by Rahul
• 3,380 points
2,685 views
+1 vote
2 answers

What is coercion in Polymorphism?

Implicit type conversion is called coercion polymorphism. ...READ MORE

Jun 25, 2019 in Java by anonymous
2,684 views
0 votes
1 answer

What is the maximum Java heap size of a 32-bit JVM on a 64-bit OS?

32-bit JVMs which expect to have a ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
2,679 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,668 views
+1 vote
1 answer

What are the types of memory in JVM?

The different types of Memory in JVM ...READ MORE

Mar 7, 2019 in Java by Priyaj
• 58,090 points
2,663 views
0 votes
1 answer

How can we import javax.servlet API in Eclipse?

Before installing Eclipse, ensure that you are ...READ MORE

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

Creating an instance using the class name and calling constructor

Yes: Class<?> clazz = Class.forName(className); Constructor<?> ctor = clazz.getConstructor(String.class); Object ...READ MORE

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

Get selected text from a drop-down list (select box) using jQuery

Select elements typically have two values that ...READ MORE

May 30, 2022 in Java by gaurav
• 23,260 points
2,627 views
0 votes
0 answers

Javamail Could not convert socket to TLS GMail

I want to send an email using ...READ MORE

May 2, 2022 in Java by Kichu
• 19,050 points
2,617 views
0 votes
2 answers

How do I convert a String to an int in Java?

Use the lines of code mentioned below:- String ...READ MORE

Feb 9, 2022 in Java by Soham
• 9,700 points
2,617 views
0 votes
1 answer

While using next() or nextfoo() , the upcoming nextLine() is skipped by scanner

That's because the Scanner.nextInt method does not ...READ MORE

Jun 6, 2018 in Java by mitto
• 160 points
2,617 views
0 votes
2 answers

How can I convert byte array into hex string in Java?

public static String byteArrayToHex(byte[] a) { ...READ MORE

Aug 29, 2019 in Java by Sirajul
• 59,230 points
2,610 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,608 views
0 votes
2 answers

How can I invoke a method when the method name is in the form of a given string?

You could probably use method invocation from reflection: Class<?> ...READ MORE

Aug 19, 2019 in Java by Sirajul
• 59,230 points
2,606 views
+1 vote
1 answer

How to calculate days between two dates?

You are making some conversions with your ...READ MORE

Aug 28, 2018 in Java by Frankie
• 9,830 points
2,605 views