0

I'm trying to develop a plugin for an FOSS application written by someone else. All I need to do is take a single class I've written, package it in a JAR file, and copy the JAR file to a directory in a pre-existing installation of the application.
When the application sees my JAR file, it should load it on startup. Problem is, it doesn't seem to be able to load my JAR file.

According to their docs, my manifest may need a CLASSPATH specified.

My JAR file structure is simply: MyJarFile.jar/MyClass.java

It's literally just a JAR file with a single JAVA class file inside it.

I'm new at this, and all the manifest file examples I'm seeing on Google seem to reference other JAR files.

Do I even need to have a CLASSPATH in the manifest?

If so, how do I reference MyClass.java?

I'm using IntelliJ and Maven (for the first time).

Thanks.

Mattzees
  • 23
  • 1
  • 3
  • This question is different because I'm asking if I need to include a classpath in a JAR file with only one class. Other questions I see are not about self-referential manifests. They are asking about how to refer to other JAR files. That being said, I've solved the problem. – Mattzees Oct 30 '17 at 20:36

2 Answers2

0

Check out the article "Setting an Application's Entry Point" in the java docs: https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

You need to add a line to the manifest like "Main-Class: MyClass" if you haven't already in order to run the jar.

Do you need to reference classes from another JAR from within your JAR? If so, you will need to add to the JAR's classpath. See https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html for how to do that.

In general, I would suggest reading the java docs info on JARs https://docs.oracle.com/javase/tutorial/deployment/jar/index.html

If you still need help after reading that, please explain your specific use case in more detail, e.g. share actual code or error messages

jason
  • 1
  • 3
  • Thanks for your answers. I'm pretty inexperienced with IntelliJ and Maven. It turns out that I had to create a new module inside the project, and manually add the compile output of the module to my JAR file. That was a pain, but thanks for helping me out. – Mattzees Oct 30 '17 at 20:40
0

Try this: Click "File" -> "Project structure" -> "Artifacts" -> right click your jar file and choose "Put into output root"