I try load htmlunit jar files to micronaut project , set class path correctly but IntelliJ can not resolve the classes ,
However I can import the same jar files successfully to grails 4 project
Note : I use amazon corretto version 11
There is not enough information in the question to know for sure what is wrong. One possibility is that the dependency has been added in your build file (maven or gradle) and the IDE is out of date and not sync'd with what is in the build file.
Can we load any external jar file to micronaut project
Yes. In fact, there is no such thing as a Micronaut project that does not do that.
I try load htmlunit jar files to micronaut project , set class path
correctly but IntelliJ can not resolve the classes
If the CLASSPATH is set correctly, then IntelliJ will be able to resolve the classes. If IntelliJ can't, I think that means the CLASSPATH is not setup correctly.
Related
I have such an application with an IntelliJ-Idea IDE that has a Springboot configuration that errors out and gives the following recommendation:
The following method did not exist:
org.springframework.context.ConfigurableApplicationContext.setApplicationStartup(Lorg/springframework/core/metrics/ApplicationStartup;)V
The method's class, org.springframework.context.ConfigurableApplicationContext, is available from the following locations:
jar:file:/C:/Users/tlmitch/.m2/repository/org/springframework/spring-context/5.2.8.RELEASE/spring-context-5.2.8.RELEASE.jar!/org/springframework/context/ConfigurableApplicationContext.class
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.context.ConfigurableApplicationContext
I'm relatively new to IntelliJ-Idea and Springboot. If this were say Eclipse - I would probably just go to the Java Build Path and add the jar file that contains the class.
I'm less familiar with IntelliJ. So far if something is missing, I've just been running 'npm install' and that usually takes care of it.
Any suggestions?
Thanks much
If you've added Spring dependencies in your pom.xml file, they might be conflicting with the Spring dependencies in the lib folder in your project directory. Deleting the lib folder will fix this. (just make sure your project does not depend on other libraries in the lib folder before deleting).
As error suggests:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.context.ConfigurableApplicationContext
you need to make sure your classpath contains only one such class. You can use Navigate | Class action to see if there are multiple versions of this class exists in project and exclude the duplicated library dependency in Maven pom.xml file.
I'm trying to find more information on how eclipse handles Running a project.
I want to understand it more because I have an issue I'm currently having where apache-poi .jar files which have been included into the classpath of my project will work properly when the project is ran through eclipse, but will not be detected when going to the same projects folder and running the main jar file to start the program.
It gives me the error: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Cell (although sometimes instead of Cell, it's Sheet)
What could I consult to understand what is going on here, and possibly solve this issue?
Your NoClassDefFoundError indicates that the library was not available while running the jar.
This depends upon how you are exporting your project into the jar file.
If you're using eclipse to do so, you can:
Export->Java->Runnable Jar to create a jar that includes its dependencies
Make sure to check Package required libraries into generated JAR.
This will make all your jars (in build path including apache-poi.jar) as a part of the final jar.
It runs from eclipse because libraries are on the build path of the eclipse which makes them available in the classpath.
I am using intellij to create a jar file. I have 5 jar files in the project as dependencies. I have added these 5 jar files in the artifact setting as follows.
I am able to run the project fine in intellij but when I try to run the jar I created it says it cannot find the class of one of the jars, which does not make sense to me. I have even tried making the jar with editing the classpath in the artifacts settings. Any help would be appreciative.
Thanks.
The path of the jars will only works well for your IDE because the IDE configured the path environment for testing, but once you run your code without IDEs, the path will follow your default setting with the system environmental variables.
I'm completely new in Spring and followed this tutorial http://tutorialspoint.com/spring
and this video too http://www.youtube.com/watch?v=ZwMwfGNrRtE
And according to this i downloaded spring-framework-4.0.6.RELEASE-dist.zip from here
I did extracted those zip files,
Now i'm unable to locate jars files into folder, But www.tutorialspoint.com/spring says It contains this pic.
But into my folder(which i downloaded spring framework), I can't locate these library please help!!
I did search all jar files in that folder but i could find only this pic
and not being able to find these jar files:
antlr-runtime-3.0.1
org.springframework.aop-3.1.0.M2
org.springframework.asm-3.1.0.M2
org.springframework.aspects-3.1.0.M2
org.springframework.beans-3.1.0.M2
org.springframework.context.support-3.1.0.M2
org.springframework.context-3.1.0.M2
org.springframework.core-3.1.0.M2
org.springframework.expression-3.1.0.M2
commons-logging-1.1.1
Well surprisingly, the dist for release 4.0.6 does not contain the jars for 3.1.0.M2 ! More seriously, under lib dir on related zip file, you will find all the jars for spring 4.0.6.
But you must have a minimal knowledge on your build environment be it maven, eclipse, Netbeans + ant, Netbeans + maven, ...
And do not forget the documentation for spring that explains what external jars are required for some operations. Notably commons-logging-1.1.1 even if the manual explains how to use other loggin utilities.
You may want to consider using Maven, as opposed to manually downloading jar files and referring to them explicitly.
With Maven, you'd declare a dependency on the spring framework (including specific version) and you'd have all of the dependencies downloaded to a local repository, including transitory dependencies (you'd only need to specify the framework itself, for example, although in your case you'd probably need to include security and/or mvc.)
I have a plain Java project (not a plugin project) which I want to add to a classpath of a eclipse plugin which I am developing. But in web projects I can add that project as a build path and it works fine. But I tried same thing in eclipse plugin, I am able to compile successfully, but at run time I am getting java.lang.ClassNotFoundException.
I know OSGi quite well and I know how to add OSGi into an classpath (using export-packages) but what I want is to add Standard, non-osgi project into an classpath, so that I wont' get runtime errors. Is there anyway I can achieve this?
I can export project as a jar file or make it as a plugin project and it would work fine. But that's not my option currently because, still that API is in pre-alpha stage, and there would be lot of changes going on. So I am trying to avoid pain of exporting it as jar file everytime. Is there any option for me other than this?
I have a similar situation: I want non-OSGi Maven dependencies integrated into the classpath of my plugin. I succeeded with a roundabout solution, which I think is the best I could get.
I have a build step outside of Eclipse where I copy the class files of the dependency into the plugin's lib folder. The lib folder is specified in MANIFEST.MF as an entry in Bundle-ClassPath and (here comes the hack) as a source folder in build.properties. That was the only way to make the plugin work both when launched from within Eclipse and when exported.