Unable to access JAR included in IntelliJ plugin from preloading activity - java

I've included a language server JAR in the lib folder of my IntelliJ plugin for my custom language plugin. I've also added it under dependencies in my build.gradle file like so:
compile files('lib/MyLangServer-1.1.jar')
I'm trying to access/run this jar from a preloading activity and while I can use idea.plugins.path to access the correct path to the installed jar when using runIde to test a sandbox instance of the plugin, when I build the plugin and install it from disk as a zip, the path is now returning null.
Is this the correct way to reference the jar, or is there another way that I'm missing, or could there be some other issue? Thanks in advance.

Related

Creating a jar from maven project Intellij

I created a new maven project in IntelliJ and set packaging to jar and when I build it, there is a jar file target folder. But when I run the file I get the error as
no main manifest attribute, in QeToolHelper-0.1-SNAPSHOT.jar
I have created jar file using maven-assembly-plugin. I have added these lines in pom.xml for that.
Tried few methods described in other similar questions but to no avail.
Have you looked at SpringBoot and associated plugins. It can be used to build a standalone java applications.
With regards to your specific issue, that error is symtomatic of a failure to declare main class in your manifest. The main-class attribute in the manifest tells the jvm what class to load from the built jar. Looks like the settings in your maven config are failing to generate the resources correctly.
I was able to solve this issue by creating jar package from maven.
Running the build package created the jar in target directory.

Generate sources from a local jar file in Maven

I have a locally stored jar file that I believe I need to generate the sources in order to consume it in my project.
I am using JDK 8, IntelliJ and Maven 3.5.2
I have installed the jar file into my local .m2 folder.
Perhaps I am missing a goal in my maven lifecycle or a plugin?
Not had to use a local jar dependency before so any help appreciated (I'm a tester not a developer)
I've attached a screenshot (apologies for all the obfuscation of package names that I feel might be commercially sensitive - possibly overkill!)
Note the red underlining in the src test....folders where the classes cannot access those within the jar dependency.
I have added the dependency within the pom.xml file also and it shows no errors.
I feel I should have run something like -Dsources=target/mycool-project-3.0.17-SNAPSHOT-sources.jar when using the mvn install:install-file command (which I used originally when installing to my .m2. However I tried this with no success.
Or maybe I need to mark the resources as a root within IntelliJ
Currently in Project Structure -> Libraries I see:

Eclipse is showing me the jar, but I'm unable to use the classes in it

I'm building an existing project with Maven in Eclipse and all the dependencies are downloaded. But some of my classes using some classes from a specific jar are not found : the import statement shows an error.
The strange thing is that when I browse the Maven dependencies in Eclipse, I see the jar. I'm also able to unfold the jar, and browse in the packages, and see the classes in it. So as far as I can say, the jar is here in my classpath, available to my project. But somehow, it's not seen by my code. I've tried rebuilding, from Eclipse and from mvn command line, but I still have the same issue.
Any idea where that issue could come from ?
Thanks
One root cause would be that your jar is corrupted. Not corrupted enough to make it unavailable in Eclipse, but corrupted enough to prevent Eclipse from using the classes inside.
To make sure of this :
go to your local Maven repo, where the jar is supposed to be.
try to open the jar with your zip tool (Winzip or equivalent)
if you get an error saying your jar is corrupted, then all you have to do is delete the directory containing the corrupted jar, and build again your project with Maven : jar file would be downloaded again from your remote Maven repository.
If this time you're able to open it, then probably Eclipse will also, and you'll be able to use the classes inside and your problem will be solved.
If you're still unable to open it, check if the jar is not corrupted on central repository itself.
Had you add the jar file to your Build Path, if not, then you can not find the classes in the jar file.
Try to do this:
In Eclipse:
Right click on the jar file --> Build Path --> Add to Build Path.
Then try again if you can find the classes in the jar file or not.

How to build eclipse plugin via commandline

I need to integrate a existing Eclipse plugin project into our build factory. I compiled the plugin with javac and created a jar file, but it is not working as plugin for Eclipse. I receive a lot of exception "unable to load class".
Google return mostly Maven but I can not change the existing build process.
Does anybody has an idea what is required to do this?
put your created jar in eclipse\plugins folder and restart eclips.

NoClassDefFoundError in eclipse plugin execution

I'm building eclipse plugin that uses JDT/AST.
Building the plugin works fine, but when I tried to run the plugin. I go this error message.
It complains that the ASTVisitor class is not found.
I checked the org.eclipse.jdt.core***.jar is in the build path with User Libraries.
What might be wrong? Do I need to setup execution path that points to jar files?
Eclipse plugins manage dependencies using the Manifest.MF file. Check in the dependencies tab of your Manifest.MF file that you have org.eclipse.jdt.core as a required plugin.

Categories