Attaching the source to a library in eclipse [duplicate] - java

This question already has answers here:
How can I link source to a jar package in eclipse?
(4 answers)
Closed 7 years ago.
I downloaded this library for low level Java keyboard hooks:
http://ksquared.de/blog/2011/07/java-global-system-hook/
It works great, but I want to attach the source to it. The source is included as .java files, but when I go to attach them to the library in eclipse it only wants a jar or zip file. I tried zipping the .java files but it didn't work. I've never attached a source before, can someone help me out?

You can attach the source as either a zip file, a folder in the workspace or an external folder. In your project, right click and select Build Path -> Configure Build Path and then in the libraries tab find your library and expand it. There will be a line there about source attachment. On that like, hit the Edit button and then select the location of your source files.

Related

Eclipse Class File Editor Source not Found when adding library to java project

I tried to add a library to my java project in the form of a .jar file however when trying to view any files contained within the library this banner is displayed above them. I'm using eclipse IDE do I need to worry about this and if I do how do I go about fixing it?
If you have the RJ4-2.0.6's source, you can zip it and set the path's zip file clicking in the attach source's button below:

Editing java file within jar library

I need to replace one word (REPLACE with MODULATE) within the StdDraw3D.java file. I have opened the jar jd-gui and am pretty stuck now. I have been looking for videos or websites and cant quite find a way to do it. Any help would be greatly appreciated. I have not copy paste the code as i don't need help with code just how to edit or replace the original java file.
You have to download the complete source code for StdDraw.jar, update the required java file and rebuild the code again to get the updated jar file. Then use the updated jar in your project.
Steps:-
1. Download the StdDraw.jar
Extract the jar file in folder by right click on it and click on extract.
Copy the StdDraw3D.java file and edit and make required changes then compile it again. Then copy the changed class and java files in the above folder.
Now again create jar file out of that folder.

How do you edit a dependency/external library in android studio? [duplicate]

This question already has answers here:
How do I add a library project to Android Studio?
(31 answers)
Closed 7 years ago.
There is a lot of information about adding libraries and dependencies, but I haven't been able to find any useful information on being able to actually edit a library.
I have added https://github.com/jdamcd/android-crop as a dependency in my project, but I would like to edit some of its features, mostly layout related stuff. However, when I go into browse the files Android Studio says
"files under the build folder are generated and should not be edited" and when I edit them they are returned back to their pre-edited state once the system builds.
I also tried editing the files in notepad++ and the same problem occurs (they are returned to their pre-edited state on build).
Can someone tell me either how to edit the library or a workaround whereby I can change the layouts/some java without having to copy and paste the entire library into my project to make it editable?
Thanks in advance,
God speed.
Edit: The answer is instead of simply adding the library as a dependency in the build.gradle file using this code: compile 'com.soundcloud.android:android-crop:0.9.10#aar'
You have to add it as a module instead of just an external dependency, then you can edit the files.
If anyone is wondering how follows these steps:
Create library folder (call it whatever you want) in the root directory, i.e. the first folder you go into to get to the app and its contents.
Download the library, unzip it.
Put the folder from step 2 in the folder you created in step 1.
Add the module to the settings.gradle like so:
include ':LibraryContainingFolder:ActualLibFolder'
Sync and clean
Go to project structure in Android Studio, click on the main module, normally called app, click on dependencies tab, then click the green plus, then click "Module dependency".
The module should appear written as the containing folder and the library folder in it separated by colons 'something:somethingElse'. Add the module.
Sync, clean, buid etc.
You should add the library as a module in Android Studio, by downloading the code from the Github repository you're interested in (and removing the line under dependencies that you added to build.gradle)
Then follow the steps in this answer: https://stackoverflow.com/a/16639227/1065810

Use of .project and .classpath files [duplicate]

This question already has answers here:
What's in an Eclipse .classpath/.project file?
(4 answers)
Closed 8 years ago.
I have some doubts regarding the files .classpath and .project. I'm using eclipse IDE. I created a project. In that project is see that two files are created. They are
.classpath
.project.
Following questions I have:
Can I know what are the main differences between these two files(.classpath & .project)?
What is the main purpose of .project file?
Can i use .project file in place of .classpath file?
Whether .project file is created in all java IDE's?
Any help is highly appreciated
Most Java IDEs have their own method of storing metadata they need to assist you with your project. Eclipse uses the files you mention. IDEA uses a different file (or a directory if you choose that option).
You generally shouldn't edit these files directly unless you are trying to do something tricky - they are really there for the IDE, not for you, and are not required if you compile your project using an external tool such as javac, ant or maven.
As #geoand mentioned, these files are usually not added to source control as they generally relate to configuration specific to your machine (such as directory structure, etc) and they can be regenerated if required.

How to use jar file in Eclipse for android appllication [duplicate]

This question already has answers here:
How can I use external JARs in an Android project?
(12 answers)
Closed 9 years ago.
I am new in using jar files in Android application. While checking code for Android apps code.google.com suggested the jar files. I don't know how to use the classes from jar files. Please help me!
Thanks
Just put the jar in the libs folder of the project, then it will automatically be added to your project by Android SDK.
Now the code from the jar is accessible in your code.
If you added a jar containing the package org.jartest with the class IAmAnObject. You should be able to write IAmAnObject test = new IAmAnObject(), right click IAmAnObject in eclipse and select import org.jartest.IAmAnObject.
Create a folder that is called /libs at the root directory of your project, and put your jar files in there.
I don't know about eclipse.
The way you use a external library in an android project is by creating a 'libs' folder in the projects source folder and putting the jar files in their.
Don't forget to add the path of libs to the build path so they are available when building the final project (in eclipse it's right click the jar and select 'add to build path'
It has already been answered and a definite duplicate but I cannot seem to paste the answer URL.

Categories

Resources