No "Add to library" button when on a file - java

I am trying to add this fil(math parser) to my library, but there seems to be no "add to library" when i right click it. Any help?
Here's the website that I downloaded the files from idk if it will help but it's here: https://mathparser.org/mxparser-api/
I use JDK 8.

The easiest way to manage dependencies for a library is to use a build tool like Maven or Gradle. These tools help you to download and utilize dependencies in your own software and give attribution to the original authors as well as include the necessary license files. You tagged this with Android Studio so I assume this is going to be a library for Android applications. Most Android applications use Gradle as a build tool. Your application probably has a build.gradle where you can more easily manage your dependencies.

Instead of jar download I suggest just to add proper dependency to the gradle file
Maven – Gradle
implementation 'org.mariuszgromada.math:MathParser.org-mXparser:5.0.6'
Maven – Gradle (Kotlin)
implementation("org.mariuszgromada.math:MathParser.org-mXparser:5.0.6")

Related

How to export a java project from eclipse that contains all libraries required to compile?

For a project I completed a game in Java on Eclipse using LibGDX. I now need to turn in the source code to my professor. When I export the project and try opening it on a new computer, about a dozen libraries are missing.
I would like to export my entire project so that when the project is opened in eclipse, it will still compile. Is there any way to do this? I know that runnable jars come with the .jar files of the dependencies and no source code, but I need both.
Thanks in advance
Libgdx required number of dependent jars so it's hard to manually add all jars into project.
Make your project gradle based so that When you import your project through gradle into another System then gradle do most of your task* for you.
*gradle try to find dependent jars in file system if already exist then link with your project if not then it download from given repository and link them in your project. Make sure your system is connected with internet when you build your project.
I highly encourage to use Android Studio or IntelliJIDEA.
On window, by default all jars are stored inside
C:\Users\User_name\.gradle\caches\modules-2\files-2.1
In Mac OSX
/Users/User_name/.gradle/caches/modules-2/files-2.1
When you want to deploy or packaging for the desktop run this command on your IDE terminal.
gradlew desktop:dist
You can use maven or gradle to build your project, take a look of one of the tool and it's won't take you too much time. these tool could help you define your own way for build
A much easier way you could use "fat jar". this is an old tool for build a jar with all lib you need and could be run in any place.

Use Maven Library without Drinking Maven Koolaid

I want to use the diffplug/Durian library, but do not want to use Maven. Is there a way to use a Maven library without using Maven itself in a project?
This has a link to the .jar and lists it's dependencies.
http://mvnrepository.com/artifact/com.diffplug.durian/durian/3.4.0
Download the jar - then all the jar's dependencies and their dependencies and add them to the class path.
I found that IntelliJ IDEA allows for exporting of a Maven module to a JAR, that can be used in non-Maven projects.
https://www.jetbrains.com/help/idea/2016.1/downloading-libraries-from-maven-repositories.html
And needed to know what a "Maven Coordinate" was. I found it for the library in question at https://mvnrepository.com/artifact/com.diffplug.durian/durian/3.4.0, and it is the string "com.diffplug.durian:durian:3.4.0".
Basically, follow Project Structure->Project Settings->Libraries->"+"->New Project Library->From Maven. The resultant dialog takes a Maven coordinate, and has a "Download To" option, that will make a nice JAR at the specified location, from the Maven library you import. Can add source and javadocs as well. After doing the download, you navigate to the system folder containing the new JAR, and stick it in your real non-Maven project (an Eclipse project, in my case).

Adding Volley library to android project in Eclipse Luna

I've created an Android project in Eclipse and I would like to add the Volley library to it. Searching on the web, I've tried these approaches:
Copy the .jar into the libs folder and right-click and add it to build-path.
Open the library as an android project, mark it as library and add it as a reference in my android app.
Nothing works. I still cannot access the classes provided by the library by importing the classes like follow: com.android.volley
Someone has a solution for this ?
The Solution:
Try this:
Add volley.jar to the libs folder. Don't add it to the build
path.
In Eclipse go to Project and make sure Build Automatically is selected.
Now in Project, click on Clean:
Project -> select Clean -> select the project.
As Volley doesn't have any resources like styles, layouts etc., its not necessary to reference it as a library project. The above should work, provided all steps are followed.
If this doesn't work ...
Make sure the library has not been added to the build path. If it is, then remove it. Now, try:
Closing and re-opening the project.
Restarting the IDE (last resort).
The build process for Volley has changed to Gradle. If you just want to use the library without building it, you can get the Jar from Maven or scroll down to the instructions to building it yourself lower in this answer.
Maven
An easier way to obtain the Jar file is to download it directly from Maven Central. You can find the latest version with this search:
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mcxiaoke.volley%22
At the time of writing the 1.0.19 version can be found here:
http://search.maven.org/remotecontent?filepath=com/mcxiaoke/volley/library/1.0.19/library-1.0.19.jar
Gradle
The new way to do it is to build the project using Gradle.
You can do this by running:
git clone https://android.googlesource.com/platform/frameworks/volley
gradle build
This will create a file in
build\intermediates\bundles\release
Then add this file into your libs folder and add it to your project.

How to import project - intellij

I am experiencing difficulties to install some project based on a build.gradle file. I was told in a precedent post, that I should use Android Studio but it seems even more difficult (reported conflict for gradle 1.10 and Android Studio). So I am asking if it is possible to import the project directly in my ide, https://github.com/chrisbanes/ActionBar-PullToRefresh. If yes, should I put the library folder below in my libs folder ? Here's a screen of the file hierarchy
Since you are using Android Studio and Gradle, you could import it as suggested by the QuickStart page :
The easiest way to add ActionBar-PullToRefresh to your project is via
Gradle, you just need to add the following dependency to your
build.gradle:
dependencies {
mavenCentral()
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
I believe this is by far the easiest way to include that great library in your project.
If you are using Eclipse, you can still use the library, just download the project and create a create a new library project with the code from "library".
Check the guide http://www.jetbrains.com/idea/webhelp/cloning-a-repository-from-github.html
and other github integration http://www.jetbrains.com/idea/webhelp/using-github-integration.html

Jar mismatch for google-play-services_lib

I've just updated some things with the SDK and donwloaded update for the ADT. Now I get a red exclamation mark in the Project folder.
The console tells this:
Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are
identical (check is based on SHA-1 only at this time). All versions of the libraries must be the
same at this time.
Versions found are:
Path: C:\Media\Eclipse Workspace\project1\libs\android-support-v4.jar
Path: C:\Media\adt-bundle-windows-x86_64-20130522\sdk\extras\google\google_play_services\
libproject\google-play-services_lib\libs\android-support-v4.jar
Jar mismatch! Fix your dependencies
Had to say, that I created a project importing google-play-services_lib to set as library in other projects ass this where I had to use google maps.
In Java Build Path\Android Private Libraries I've got 2: google-play-services.jar and android-support-v4.jar.
The console is telling you that you have to different copies of the support library. When Eclipse sets up the project for the first time it will add a copy of the support library. This copy is probably different than the one that comes with google play services library. Make sure that there is a consistent version of the support library across your project.
Dont Include the android-support-v4 in the library , instead you can add it to your project as an external jar using build path menu > add external jar
You can refer to
This and This
.
For each project and library, right click on your project in Eclipse go to Android Tools > Add Support Library. This will download the latest version. Upon doing this on each referenced project and library, they should all then have the same version of the support library and you should no longer see this error message.
Finally I solved.
I removed and installed the "Google Play Services" from the SDK.
Import again the google-play-services_lib project
On Other project's properties in the android tab delete the library and add again
Copy the lastest android-support-v4.jar to the libs folder

Categories