IntelliJ is unable to detect jdk.crypto.cryptoki package - java

I'm trying to use jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11 in IntelliJ, but for some reason it keeps throwing errors. It seems like it's unable to detect this package. One of the solutions was to add --add-exports jdk.crypto.cryptoki/sun.security.pkcs11.wrapper=ALL-UNNAMED in the settings, which I did, but now it throws a compile time error in the IDE:
Error:(5, 20) java: package sun.security.pkcs11 is not visible
(package sun.security.pkcs11 is declared in module jdk.crypto.cryptoki, which is not in the module graph)
I'm using Java 11. It works fine when I try to compile and run it over the terminal

Related

Compilation with javac fails, with eclipse-compiler it works

I'm trying to write a simple ant build to compile a project.
The project is in eclipse and there it compiles successfully (with the eclipse-compiler).
But with ant (using javac) it appears an error and i don't know how to resolve it.
Structure of the used jar:
com
xxx
a <= package
b
a.class
Codeblock of my class:
Object o = com.xxx.a.b.method();
^
The exception of ant is:
error: cannot find symbol
symbol: variable b
location: class a
I think eclipse uses the package first to try to compile the code. javac seems to think that a is the class.
Is there a way to resolve the problem without changing the jar?
It looks like either package name is different or you have multiple class files of the same name. I would suggest checking the import statements and adding the specific jar file to classpath while compiling using javac or ant command.
To find the exact jar file, use ctrl+T then paste your class name in the box and it will tell you the jar file. Add that jar file to your ant classpath and build.
I didn't find anything in the Java Language Specification that this is an error, so it might be a javac bug.
Since it is a javac vs. Eclipse compiler thing, try one of the following:
Use the Eclipse compiler in the Ant script
If it is a javac bug, the bug may be fixed in a newer (update) JDK version
If your code does not directly reference class com.xxx.a, compile the code with the JAR in which the class com.xxx.a was removed

IntelliJ - Spring Boot application suddenly will not compile

I am developing an application using Spring Boot. It is fairly straightforward. It uses Quartz to schedule Pentaho jobs to import data into a Postgres database. It contains only 1 module(the original, no extras have been added. The project started out using Java 7 but within the first couple of weeks switched to Java 8. After the switch, everything ran fine(i.e the application would compile and launch). I started coding some new classes and when they were completed, I went to test them and the application wouldn't compile. I got an error stating that Java 8 was the wrong source code. I checked my project structure and both Global and Module compilers were set to Java 8. I did find that Gradle was still using Java 7. I changed Gradle to Java 8 and the error changed. The compile was still failing due to the following errors:
• error: package org.quartz does not exist import org.quartz.*;
• error: package org.quartz does not exist import org.quartz.*;
• error: package org.quartz does not exist import org.quartz.*;
• error: package org.quartz.impl does not exist import org.quartz.impl.StdSchedulerFactory;
• error: package org.quartz.impl.matchers does not exist import org.quartz.impl.matchers.GroupMatcher;
• error: package org.pentaho.di.job does not exist import org.pentaho.di.job.JobMeta;
• error: package org.pentaho.di.core.exception does not exist import org.pentaho.di.core.exception.KettleException;
• error: package org.pentaho.di.core does not exist import org.pentaho.di.core.Result;
• error: package org.pentaho.di.core does not exist import org.pentaho.di.core.KettleEnvironment;
Quartz and Pentaho are not being found even though they are set up in the Project Structure:
I am fairly new to IntelliJ so any suggetions on what else to check or how to proceed would be greatly appreciated.
This can solve your problem. First clean your gradle project. After that you will need to refresh all your gradle deps by clicking on this blue arrows in gradle tool window.
I am not sure if you found a solution, but I was experiencing a similar situation. I tried to remove current modules in the project settings, then added the project modules again. I then refreshed my Gradle and rebuilt my project.

Android Studio : "cannot find symbol" error after adding dependency

I am using the Unity engine to generate an android studio project.
My main project's main activity has the following code in its NativeActivity class:
return mUnityPlayer.injectEvent(event);
Everything compiles and works fine.
However, when I add a certain 3rd party library (androidNative) as a module
I get the following error when I try to compile :
Error:(86, 89) error: cannot find symbol method injectEvent(MotionEvent)
This is surprising, because it is an error in a file from the original project (not the module I added) and I only added a reference.
What is the reason behind this scenario? How can adding a module as a dependency of a project cause a file in the original project to not compile?

compile error: The import xxxx cannot be resolved

I am developing a Java project using Eclipse. The project uses another project called engine, which I have added in my project build-path. As I need to call a dabo class, called House, in one of my project class, named Window, I have used the following code as usual:
import ee.asus.kernel.House;
I got however the following error in compiling time:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The import ee cannot be resolved
House cannot be resolved to a type
House cannot be resolved to a type
House cannot be resolved to a type
at main.ee.asus.GUI.FrameWindow.Window.<init>(Window.java:10)
at main.ee.asus.GUI.StartApplication.main(StartApplication.java:13)
It's worth to point out that my prject and the dabo project use the same directory/packages names. Does anyone have a clue where the error may be?
The error can't resolve the first part of the package name: ee. Are you sure the package starts with ee? I see your Window class package starts with main.ee, does your engine project start with the same package structure?
I sometimes get weird behaviour with missing class files etc. when Eclipse is out of sync with the filesystem.
You could try refreshing all of your projects and doing a full rebuild.
I have been experiencing the same problem. I have an app A1(tablet version app) calling another app A2(phone version app). Upon calling, I see the same error message:
java.lang.Error: Unresolved compilation problems:
The import xxxxx cannot be resolved
xxxx cannot be resolved to a type
xxxx cannot be resolved to a type
xxxx cannot be resolved to a type
After poking around for a while, I realized the problem was the A2 doesn't run on tablet at all. It's weird because the immediate previous version of A2 runs perfectly on the same tablet(I have been on board only for 1 month). So I decided there was something wrong in the build config.
Finally, I fixed the problem by changing the order of Java Build Path. Although I have no idea why it worked, hopefully this will shed some light on your problem.
Look for the House class in your second project, opens it and see what package it is in.
(line "package xxx.yyy.zzz;" at the beginning of the House.java file)
Then make sure your Window.java file (class main.ee.asus.GUI.FrameWindow.Window) does have the line "import xxx.yyy.zzz.House;" in it.
In my case it was a version conflict.
I'm using maven and updated many packages and bumped versions of many projects. Maybe the reactor built mixed something up, or the transitive dependencies weren't up-to-date, or it was a change in a project without a version increment. However, rebuilding that project explicitly via maven fixed the problem.
Edit: When I think about it, it might also have been a conflict between eclipse's auto-build and building via maven on the command line.

Exception in thread "main" : java.lang.error

I've just created a project on Eclipse and imported some source files (existing project). But I can't compile it ! Ok, the project has got several source files, so I wanted to compile only the Main.java file (with eclipse not in the command line, in the command line it worked!) but all what I get is this error :
http://www.screencast.com/users/Amokrane/folders/Jing/media/82d772dd-10cd-4552-b1d0-3cf18bf39f13
As you can see the Main.java file is straighforward, just a hello world !
What's the matter ?
Thanks
"Unresolved compilation problem" means that the class hasn't compiled successfully. Eclipse will still let you run code that doesn't compile, but any of the specific bits which don't compile will throw this error. Look in the "Problems" tab to see what's wrong.
From the look of the Package Explorer view, every single class has a problem... perhaps the file location doesn't match the package declaration? That would match the position of the pink box just to the right of the vertical scrollbar for the class - it suggests that the error is right at the top of the file, which is where the package declaration would be.
You have a compilation error at the top of your Main.java file, just out of sight in the screenshot. Probably an unresolvable import or a wrong/missing package declaration.
It is simple in my case that the imported project needs 32 bit jre to run but cannot be compiled in the same. In IDE, if you click run, it will try to compile and run the project in single shot so fails due to 32 bit jre for compilation with the above reported error.
So i used 64 bit compiler and started to run and got compiled successfully but thrown error that needs 34 bit jre for some of the SWT used in the project. Again i changed the 32 bit jre and run the project, it is gone ! THE ERROR IS GONE NOW !
You can get the error "Exception in thread "main"
java.lang.Error: Unresolved compilation problem:" if your public class name differs from your file name.
example:
File Name:
ServiceRequest.java
Inside file, class is named differently; like
public class Service

Categories

Resources