I downloaded and decompiled a jar file for a plugin for minecraft, and I added it to eclipse by creating a new java project, Import > archive file > [decompiled jar.zip]
That results in this:
After that, I changed a single line of code, then I tryed to export it.
However, when I attempt to export it, I get this message:
I have no idea what I'm supposed to do to fix this. Please help.
de (and not only its content) and the other folders as well must be included in the source folder.
Try to move all the folders (except META-INF) and files to src and then create your jar.
(Note that there would be a warning if you didn't exclude META-INF because it is generated you would override it but it wouldn't prevent generating the jar).
NOTE
I don't know what you will do later with this but you'd better use Maven, Gradle (or even Ant) to manage you future jar builds.
Related
I've currently finished my project, but can't get it to work when it is exported. I use JAXB to read and write XML Files and also have dependencies on other external Folders, which are needed to use a POS-Printer.
I've managed to link my external XML Save-Files with absolute paths, but not with relative paths. So that worked, although not the way i wanted. Yet, using the external class folder for the printer didn't work at all.
This means, that in my Eclipse Project Build Path i've added a class folder, which contains all of these needed files (which are not only jars, so adding them one by one wouldnt work). So exporting my project to a jar either includes all the files into the jar itself, or doesnt include them at all.
Everything works perfectly in Eclipse, but not when i export it.
My folder structure looks like this:
src
/model
/view
/control
data
/articles.xml
/...
JavaPOS <--- needed folder with all its files
/jpos.xml
/xerxers.jar
/swt-..-.dll
I've tried:
InputStreams is = getClass().getResourceAsStream(url);
absolute paths
manipulating the manifest file and/or jar structure
runnable and non runnable jars with nearly every combination of options
putting the files inside the library "by hand"
changing the build path of the project
My Question is:
How do i get my jar-file to know where these files are?
EDIT:
Do you think Maven or an Ant file could solve my problems? I don't have any experience with those.
The Problem was, that i had more than one JRE installed and that the one eclipse was using, had all the dll files, but the other ones didnt have it. So i had to add them manually, because reinstalling the drivers of the printer didnt change anything. Gotta fix that somehow, but right now it works and that is all i wanted.
Turns out i didn't even need that Folder, just needed one file out of it and the missing dlls.
I have a Java JAR file that was developed to run in the browser. It works fine. There doesn't appear to be any sort of build file associated with the source code I've been given and I'm attempting to create a project and/or build script.
The source code references some third party code. What I've done is unzipped the JAR file into a folder that has this structure:
\App\src\com
\App\src\META-INF
\App\src\applet
The "com" folder contains subfolders which contain the .CLASS files for the third party libraries. "applet" contains the .JAVA source code files (one folder, maybe 15 files).
The code appears to be written in 1.4 syntax (I manually attempted to compile some of the .JAVA files and it complained that some things were deprecated and/or required the older version).
I created a Java Project in Eclipse and pointed it to the \App folder. Then I went into the Properties for the project and went to Libraries and and clicked on "Add Class Folder" and added the \App\src\com folder. Then I went to "Order and Export" and moved this to the top. I also set the Java Compiler version to 1.4.
I am getting a large number of compiler errors, all of which seem to stem from the fact that it says it can't resolve an import. This import is the set of .CLASS files contained in the "com" subfolders. The namespace matches the directory structure.
This seems like it should be really straightforward, but I've tried various things and don't seem to be making any progress. Based on what I've read I'm sure it has something to do with the pathing but I'm at a loss at this point on how to fix it.
(I'm sure it goes without saying that I'm not a Java dev.)
Any thoughts or ideas as to where I'm going wrong?
Can you please try to right click on Eclipse's Navigator. Select Import>General>archive file> (Jar file that you want to import).
You should be getting the jar file correctly imported at this point. Do tell me if you face any problems.
I have the following setup:
there are several plug-in projects containing common utility and base classes, e.g.:
my.util
my.util.ui
And I have one plug-in which uses them. However, I'd like to not import these utility classes as plug-ins but use linked source folders. This is not a problem at all and the "workload" plug-in is e.g.
my.actual.plugin
All three plug-ins are in the same workspace and the "actual" plug-in contains the usual "src" source folder and the following linked source folders "src.my.util" (links to my.util/src) and "src.my.util.ui" (links to my.util.ui/src). The linked source folders are bound to individual output folders (src -> bin , src.my.util -> bin.my.util , src.my.util.ui -> bin.my.util.ui).
Now, in the plug-in's build file (build.properties, or via the manifest editor) I wanted to specify that the sources of the two utility plug-ins are built into separate jars. Therefor, in the manifest editor under "Runtime" I added two additional jars ("New..." -> "my.util.jar" and "my.util.ui.jar") and under "Build" I set the appropriate linked src folders for these jars. The resulting build.properties file would be something like:
source.. = src/
output.. = bin/
source.my.util = src.my.util/
output.my.util = bin.my.util/
source.my.util.ui = src.my.util.ui/
output.my.util.ui = bin.my.util.ui/
jars.compile.order = .,\
my.util.jar,\
my.util.ui.jar
bin.includes = META-INF/,\
my.util.jar,\
my.util.ui.jar
Exporting this as a runnable jar works (let's assume for simplicity that it contains a class with a main method etc...).
However, trying to export this using the "deployable plug-ins or fragments" export wizard does bring up an error message like:
<workspace>\.metadata\.plugins\org.eclipse.pde.core\temp\org.eclipse.pde.container.feature\compile.org.eclipse.pde.container.feature.xml:4: The following error occurred while executing this line:
<workspace>\my.actual.plugin\build.xml:167: The following error occurred while executing this line:
<workspace>\my.actual.plugin\build.xml:138: <workspace>\my.actual.plugin\src.my.util does not exist.
The following error occurred while executing this line:
<workspace>\my.actual.plugin\build.xml:167: The following error occurred while executing this line:
<workspace>\my.actual.plugin\build.xml:138: <workspace>\my.actual.plugin\src.my.util does not exist.
Even when I switch on the "Use class files compiled in the workspace" option in the export wizard this error comes up.
When I don't use separate runtime jars, it works, but it's just not what I want ;-)
Oddly enough, when I export the ant build script (Export... -> General / Ant Buildfiles) the paths are correctly expanded (translated from the "virtual" relative links to absolute paths). And the ant script compiles correctly. Why the hack does it not work for exporting as a plug-in?
I hope anyone has some suggestions? Thanks in advance :-)
I see that no one else has answered this yet, so I will provide an answer/opinion that you may not like.
I strongly suggest that you avoid the use of linked source folders in your plugin projects.
The reason that you are getting the errors that you see is because PDE uses an alternative mechanism for building projects. It does not use the .classpath and .project files to determine project structure. Rather, it uses MANIFEST.MF and build.properties. It also does not use Eclipse's resource abstraction and hence linked folders are not recognized by PDE.
There may be some hacking that you could do to trick PDE into finding your linked source folders, but this wouldn't be a portable solution.
Instead, I'd recommend splitting things up so that you have multiple plugins so that you don't need to copy source folders around.
I have filed a bug report : https://bugs.eclipse.org/bugs/show_bug.cgi?id=457192
A related bug report is: https://bugs.eclipse.org/bugs/show_bug.cgi?id=66177
I think it should be solved
I downloaded an API but there is no jar file in it. It has the packages(folders) and the source code. I tried adding this in various ways in Eclipse but still I don't get the "import ...." when I press F2 on the underlined red classname. I have added projects and Jars in Eclipse all the time and it has worked. Since this is the source code should I take any extra steps in order to make it work?
Regards!
If the source is available to you (.java files) you must create a new source folder, then copy the source tree (root package e.g. the folder com or org) into the new source folder just by using a standard file explorer and copy&paste:
Edit: You could add the source files to your existing source folder as well, but I'd avoid that. Best solution would be to create a separate Java project containing just the source files of the external library. You also need proper code management, so that you do not accidentially make changes to the external source files!
You may create jar from the classes you have received in API packaging and place that jar into the classpath of the project
Enjoy !!!
I want to create an executable JAR-file from my eclipse project. It references other projects, which also reference other projects (and so on) and some JAR files.
According to this answer, everything should go "within 2 clicks". But not for me:
It reports a warning:
Problem writing mg/build/classes/META-INF/MANIFEST.MF to JAR: duplicate entry: META-INF/MANIFEST.MF duplicate entry: META-INF/MANIFEST.MF
It looks like it tries to include existing manifests from all projects, which simply doesn't make sense. I actually do not want to include any of them, just to generate a new one. I haven't found any way to switch it off. OK, it's just a warning.
It looks like I need to manually take care of all the referenced jar files... actually, Eclipse knows them, I do not.
I need to either include the content of all the referenced jar files or to copy all of them into the target folder and list them in the Manifest. I've got no idea how to do it.
I also wonder if the jardesc file is usable from ant build scripts.
I got the same error message ("duplicate entry") when, in my case
I checked the option to include an existing manifest file.
AND I specified to include MANIFEST.MF among the files to be included in the .jar.
Once I excluded MANIFEST.MF in the "Select the resources to export:" file tree of the jar generation wizard, the warning disappeared.
As for including referenced projects with your jar, I recommend making them into jar files as well, and including those in the project you want to make a jar of.
Then, make sure to set the manifest's classpath correctly.