Skip to content
Advertisement

Tag: compiler-errors

Two java files. Getting IllegalAccessError when running class with main method trying to access a method from the other file

Learning Java. I have two files, each containing one java class. When I run the file with the main method, I get the following error: Exception in thread “main” java.lang.IllegalAccessError: failed to access class TapeDeck from class TapeDeckTestDrive (TapeDeck is in unnamed module of loader ‘app’; TapeDeckTestDrive is in unnamed module of loader com.sun.tools.javac.launcher.Main$MemoryClassLoader @18bf3d14) at TapeDeckTestDrive.main(TapeDeckTestDrive.java:3) Any help please?

JAVA ERROR : package com.sun.rowset is not visible : com.sun.rowset is declared in module java.sql.rowset, which does not export it

I’m simply try to run this code: When I run it I get: Error:(1, 15) java: package com.sun.rowset is not visible (package com.sun.rowset is declared in module java.sql.rowset, which does not export it) I’m using IntelliJ and I tried to import rs2xml.jar, and that still doesnt help. Answer As of Java 9, you can not access this class directly. And

ObjectInputStream readObject in while Loop

Is it possible to read from ObjectInputStream in while loop which will terminate by exception thrown by socket timeout socket.setSoTimeout(4000); Answer When you say ‘not working’, what you really mean is ‘not compiling’, for reasons that are stated in the compiler message: Object isn’t a boolean expression, and you can’t declare a variable in a while condition. However the code

Why do I get “must override a superclass method” with @Override?

The following code generates this error message at the public void onClick line. Multiple markers at this line – implements android.view.View.OnClickListener.onClick – The method onClick(View) of type new View.OnClickListener(){} must override a superclass method I can’t understand why. This code is taken from numerous examples I’ve seen. What can possibly be wrong? Answer Check the project’s properties and verify that

Cannot make a static reference to the non-static method

Building a multi-language application in Java. Getting an error when inserting String value from R.string resource XML file: This is the error message: Error: Cannot make a static reference to the non-static method getText(int) from the type Context How is this caused and how can I solve it? Answer Since getText() is non-static you cannot call it from a static

Advertisement