I have a maven project converted into executable jar which is hosted and running just fine.
How to convert this jar src into a project in eclipse so that i can debug and do modifications to the existing files?
I have tried importing as maven, but it imports the libraries inside the META-INF, and i can't see any class files or pages.
This is the project structure JD-GUI,
Use JD GUI. Open the application, drag and drop your JAR file into it.
Related
I have made a library project that uses Async and Json/Gson libraries. It is working perfectly fine if I use this project as library project inside another Application Project. I don't want my code to be open to world so I tried to make a JAR of my Library Project. I am getting error that shows that the Async and GSON libraries can not be referenced.
Is my JAR not including the ASYNC and JSON libraries?
if not then how to do it? I have Checked the libs folder when exporting Library Project to JAR.
If Jar has included Libraries then why can't it get a reference? Is there any way that I can make a reference to the libraries present inside of the JAR of my library project?
Where am I making a mistake?
Update-1
Ok I have checked by extracting my jar and there is a lib folder there which has all the libraries that I have used in my Library Project.
Update-2
How I am exporting my Library Project as Jar.
Select Project to Export
Chose Jar File
Chose only src and lib folder.
Checked
Export generated class files and resources
Compress the contents of the JAR file
Chose Destination
Left All other checks as defaults and Finish.
I am trying to package a Java project into a runnable jar using Eclipse (version Kepler SR2). The project is using Maven (which has been fored onto me and I don't know much about it). The problem is that the project runs fine within Eclipse, but after export to Jar it doesn't find any of the required resources anymore.
Here is the folder structure:
+src
+main
+java
<packages with source code>
+resources
<folders with static resources>
+test
+java
<unit test classes>
I have also added the resource folder to the build path.
The resources are loaded using
File myFile = new File(getClass().getClassLoader().getResource("resourcePath").getPath());
This line works perfectly fine when executing the program from Eclipse, but it fails with an NPE when using the executable jar that I created with "Export>Java>Runnable Jar".
I have already to use the standard Jar export with the options "Export generated class files and resources" and "Add directory entries" checked. This leads to the same problem, though.
What do I need to do in order to correctly export the resources into the Jar?
Thanks!
Martin
Use maven-assembly-plugin:
Reference:
Building a runnable jar with Maven 2
http://www.javavids.com/video/how-to-create-runnable-jar-file-with-maven.html
Maven's default strategy is to copy resources in a separate "resources" folder and to add that folder to the class path.
When you import a Maven project, Eclipse is configured to treat the “project/src/main/resources” folder as a source folder but to exclude everything from being exported **. The temporary output folder is “project/target/classes”. You can see this in the java build path.
So, when you are inside Eclipse, resources are copied to the right temporary folder and everything works fine.
When you ask Eclipse to build a runnable JAR, it copies resources to the “resources” folder but does not add this folder to the classpath. You can see this if you open the JAR.
You have three solutions (from better to worst):
Use maven to build your runnable JAR. See: Building a runnable jar with Maven 2
Edit Eclipse’s build path to remove the “**” exclusion. This change will be overwritten every time you sync with Maven
Move your resources. See: Change maven's export resource directory
When I build a jar with Eclipse, sometime I'd like to include source or JavaDoc with the .class files in a single .jar file. I found how to do that with Maven. Is it possible to do it just using Eclipse?
TIA,
You can import a maven project into Eclipse. That's one way. Just import your maven project and perform the maven steps you do to create you jar file.
You can also export a Java project, which includes the sources and all that you mentioned using Eclipse under the File -> Export option. You will see a wizard that allows you to choose the target (war, jar, ear, ...) and the resources that should be included.
Mode details: http://www.codejava.net/ides/eclipse/how-to-create-jar-file-in-eclipse
I've tried to build my project with NetBeans 6.5; The thing is the project contains external jars added so I need them all being placed into my jar file (because it is to be signed); but IDE just places project classes in the jar :(
So my question is how to place project dependent external libs into my project JAR with NetBeans ?
I think you need something like this fat jar tutorial. I'm not sure if it's easier than building with an Ant script, but it should do the trick.
I am trying to create and use jar file in an Android project under Eclipse. I have tried various methods without any success. Here are the steps:
Create jar file from the source files jar -cf lib.jar *.java
Copy jar file to libs folder
Right click, Build Path->Add to Build path
Now, compiler gives unresolved symbols if I try to use a class from the jar file?
Can someone please let me know correct method to create and use an external jar file for the Android project under eclipse.
This worked fine for me:
1)Place Jars in assets folder.
2)Right click on project name.
3)Select properties.
4)Select Java build path.
5) Select Libraries.
6) Click Add Jars.