Add .jar to Buildpath but not Classpath within Eclipse - java

In this specific case I am creating a Minecraft mod (yea... I know) and to do what I need I am trying to add an external jar (ComputerCraft Mod) to the buildpath, but not have it to the classpath, because Forge (The mod loader) errors on duplicated mods (classes/jars). I believe this is caused by Eclipse automatically adding all the Buildpath classes to the classpath. If there is a setting that I somehow overlooked, or an option for the jar entry, that would be great. Thank you for any info/answers/documentation you are able to provide. Thanks!

Right click your project in eclipse -> Build Path -> Configure Build Path -> In popup window Click "Add External Jar" -> select the jar you want in build path from your machine.
But simply it can stated as
The classpath is used to find classes when executing a Java program.
The build path is used when Eclipse is compiling a Java program.

Related

Add project JAR to deployment assembly but not build path in Eclipse

Eclipse automatically adds everything in WEB-INF/lib (specified in deployment assembly) to the project's build path. Is there a way to override this behavior? I need for another project jar to be deployed and available at run time but not have a forced compile-time dependency on it. Thanks!
Go to the properties window of the project. Then go to java build path tab and remove the relevant other project from libraries there. Then go to projects in the same tab and select the required project by using the add option and add it. Then restart Eclipse.

Update External Jar in Android Project

All, I have an external JAR that I'm adding to my Android project. However, as my jar is consistently updating and changing. When I update my JAR, I get the dalvik VM magic number error.
I don't understand how I'm supposed to fix this?
Here's the steps I've followed.
Adding The Jar Initially
Copy JAR to libs folder in my project
Run project
My JAR is picked up, installed everyone is happy.
Updating the Jar
In Eclipse, go to the jar in libs and right click -> delete.
Copy my new jar (same name) into the libs folder.
Receive bad class file magic error.
My Troubleshooting So Far
In eclipse, Project -> Clean...
Select my project, clean it.
Run it. Same error... magic number
Project Properties -> Java Build Path -> Remove Android Private Libraries
Now the private libraries aren't being re-added. (Which equates to missing imports in my Java project) Why is this a nightmare? Any suggestions?
Turns out that my issue was caused by the multiple JDK's I had. Android was defaulting to use JDK 1.7 while my console jar was using JDK 1.8

Including a Jar in Android App

I want to include a jar into my Android package.
Unfortunately, I can't get it to work. I followed several explanations, such as this one, but I still get NoClassDefFoundErrors - at runtime, building, compiling, installing the project worked without errors.
Most answers seem to be outdated. How do I solve this issue using the current Eclipse, ADT and Android versions? Adding them to the Java Build Path like in plain Java projects didn't help.
All help appreciated.
What I have tried
Putting them into a folder and including into the project [Screenshot]
Put the jar in a folder entitled 'libs' (should be in the root of your project. Then add it to the java build path.
If that doesn't work try this:
Your Project -> right click -> Import -> File System -> yourjar.jar
Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.ja
Add your jars to libs folder. Automatically add's those JARs to your compile-time build path. More importantly, it will put the contents of the JARs into your APK file, so they will be part of your run-time build path.
You two things and the error will be fixed
Right click on Project-->Select Properties-->Go to Java Build Path--> Select 3rd tab from top i.e "Libraries" -->Click Add Jar--> Select your Jar
Right click on Project-->Select Properties-->Go to Java Build Path--> Select 4th tab from top i.e "Order and Export" --> Select(chekbox) your Jar.
For more help check this link

Cant find jar library

I imported a JAVA project in my Eclipse workspace.
In the "Problams" window it says that the project is missing some required jar libraries, and gives a path which is wrong and not where this jar libraries are located.
The libraries are in my project but in other path.
How can i point to the right path of this required files?
Thanks.
Right click on the project, go to properties, then select java build path, then go to the libraries tab and fix the entries.

User defined library

I am a newbie at J2ME. Recently, I've shifted from Netbeans to Eclipse because of some internal constraints.
I am making an App which makes use of a user-defined library. This library has only a jar file.
Now, in Netbeans there were no problems. But in eclipse, I am unable to access the classes defined in the jar file included in my library. The exception thrown is java.lang.NoClassDefFoundError.
What should I do?
Have you added the jar through:
right click your project > Build Path > Configure Build Path > Add External Jars and select your jar from there?
In case the jar is in your project dir, you can use "Add Jars" (not External).
I assume you have done it, so to the next step:
How are you running your application? In the Run Configurations there is a classpath tab - make sure your jar is present there as well.

Categories