Unreachable code in eclipse

The first message, Exception in thread “main” java.lang.Error: Unresolved compilation problem:means your code does not compile. You need to identify the error and fix it. Modern IDEs e.g. Eclipse, Netbeans, etc flag compile errors. They can help you to quickly identify the source. The second error: Unreachable Code at mycode.sample.main(sample.java:24 means that the code at line … Read more

How to resolve Unable to load authentication plugin ‘caching_sha2_password’ issue

Starting with MySQL 8.0.4, they have changed the default authentication plugin for MySQL server from mysql_native_password to caching_sha2_password. You can run the below command to resolve the issue. sample username / password => student / pass123 ALTER USER ‘student’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘pass123’; Refer the official page for details: MySQL Reference Manual

How to import a jar in Eclipse

You can add a jar in Eclipse by right-clicking on the Project → Build Path → Configure Build Path. Under Libraries tab, click Add Jars or Add External JARs and give the Jar. A quick demo here. The above solution is obviously a “Quick” one. However, if you are working on a project where you need … Read more

Node cannot be resolved to a type

I’ve seen similar behaviour in the past and know of two possible reasons: Your build path has somehow changed, leaving out your Node class, or the project providing it has compile errors, or similar. Given your description of the problem, this probably isn’t relevant in your case. Some Eclipse screwup. For me, this was always … Read more

Resource leak: ‘in’ is never closed

Why does Eclipse give me the warming “Resource leak: ‘in’ is never closed” in the following code? public void readShapeData() { Scanner in = new Scanner(System.in); System.out.println(“Enter the width of the Rectangle: “); width = in.nextDouble(); System.out.println(“Enter the height of the Rectangle: “); height = in.nextDouble();

Java console program

/* * put this in a file named CommandLineExample.java * */ class CommandLineExample { public static void main ( String [] arguments ) { System.out.println(“Hello, world”); } } type the following from the command line to compile it: $ javac CommandLineExample.java then you can run it from the command line like this: $ java CommandLineExample