Plugin created using java code is not working - java

My in tension is to create a plugin at at the run time using java code.First a created executable jar using the java.util.jar.JarOutputStream and used javax.tools.JavaCompiler for compiling the classes. And I was able to execute the jar from command line properly.
Then I tried to create a pluign by including the plugin.xml file in the jar package and compiled the classes by using the above packages and plugin is created with out any errors.
But I was using an extension point for the plugin and it is not detecting while I am putting my plugin in the eclipse product.
Then I exported it by using eclispe export option and it is working properly for me. I unzipped both the jar created programtically and by using eclispe and the contents are same.
How can I solve this issue?

Related

Adding multiple Jar files to Inelij idea

I'am working on a project which requires adding multiple jar files to intelij idea as a plugin but only one jar files gets added as a plugin to the IDE.

Compiling Java Project into Jar file by from command line instead using Maven

I am looking into the github project located at,
SymbolicRegressionInJava. I am familiar compiling java code into jar file but not one huge project using Maven. I looked into Maven and it is another complex system that need to be figured out. The bin folder has already a compiled jar file. I used a command
jar -tf symbolic_regression_1.0.jar
to see the list of classes used for the project. It has both gp and ga directories. I added ga (from another github) folder where is gp folder is at ../src/.. Instead of Maven (which I cannot figure it out even with a tutorials), I attempted manually by typing
jar cvf test1.jar *
It compiled, however, it failed to run like symbolic_regression_1.0.jar. What I am missing here?

Difference between Run in eclipse and going to the project folder and using the .jar

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.

ClassNotFound exception after renaming package

I have a Spring Boot application in which I renamed package where starting class is in. Application runs without any problem when launching from IDE (Spring Tools Suite) but when I build it with maven and run from command line with
java -jar <application_name.jar>
It says that class in old_package cannot be found. Things I've tried so far:
Clean project
Delete metadata from workspace
Copy project somewhere else and import it from there
Deleting Run Configuration and creating new one with main class in new package.
I also unzipped jar located in target folder and checked its manifest file and Start-Class param is set to old package.
You didn't update your pom.xml, and it contains references written in the form <old_package>.MyClass, whereas this should be <new_package>.MyClass. Your IDE (I'm not an expert with STS though) uses its own rules for compilation, so your program can run in it.

How to export Java app as runnable?

I created a Java project called TotalBeginner, and exported as a jar. I then reference it in a desktop app with a SWT GUI, called MyLibrary. I now want to be able to run MyLibrary outside of the Eclipse IDE (I am running Luna 4.4.0). In following the advice of other answers to questions on Stack Overflow, I export as Runnable JAR File. I pick "Package required libraries into generated JAR" - so if I understand correctly, referenced libraries like TotalBeginner.jar should be included in the MyLibrary.jar, correct? However, when I run it, it returns to the command prompt with absolutely nothing appearing to happen. Task Manager (Windows 7) shows no Javaw process. What am I missing? Thanks.
C:\Users\jimerman\>javaw -jar MyLibrary-app.jar
C:\Users\jimerman\>_
No errors, no dialogs.
I suspect in your JAR you only have classes of your own project (which is fine in fact) and you haven't put all dependent JARs in classpath (As it is complaining for unable to find org/eclipse/swt/events/DisposeListener)
It may be tedious to find out all dependent JARs and put it in classpath of java command manually.
Consider making use of build tools like Maven and Gradle, which will save you trouble in collecting dependencies, and there are plugins for them to help you to construct artifacts that makes execution easier.
For example by using Maven, what you need is to prepare a POM, put SWT (and other dependencies) as dependencies of your project.
Then by making use of shade, appassembler or assembly plugins, you can easily have a uber-jar that contains all dependencies, or have a zip files that all dependencies are put in a specific directory and you can easily execute using generated command.

Categories

Resources