Eclipse is not applying part of my patch but no errors - java

My team and I often exchange patches created in eclipse when working on the same parts of code. I just made a patch for my teammate that includes our changes he had just given me and a function I just added. When I save the patch in a txt file and open it, I see that function.
(I created the patch by right clicking on my project folder, Team -> Create Patch)
He is taking the patch and he has all the same changes in his code except for that one function. He right clicks on the project folder and Team->Apply Patch. He sees a lot of conflicts in the Apply Patch wizard because the wizard is seeing all the same code already in the patch in his workspace (minus that one function I added). He applies and gets no errors. HOWEVER, the one function doesn't go into his code.
Why is this? I thought maybe he had to revert all of his code first and then apply the patch, but it should work regardless, right?
So to be clear here was the process we just did:

Related

NetBeans save edited .jar

I am currently using a library for "Notify My Android". The library is using an outdated URL so i tried to change it. I attached the source file and now I can edit the code. Before attaching the source file it just said "compiled code". But when i save it it does not seem to save the changes. It is still using the old URL. Also the change I made is underlined in blue. I hope somebody knows how to make the .jar to accept my changes.
Thanks in advance
it's highly discouraged to modify jars you depend on simply because if you ever want to upgrade versions you'd need to modify the new jar you are looking for.
In those situations you have these options:
if it is an open source project, contribute to the project and correct the URL
try and set the property from your code (this may not be possible in certain situations)
try and extend the class you're trying to use and set the URL on the property you need (like the previous one, it may not be possible to do this)
this should be your last resource: create your own project (from the original jar), make the changes you require, package it up and add it to you app.

How to include app dependency to Android studio project?

I may be using the wrong terminology for what I am really asking. But let me describe what I need.
I have two separate apps, one was made first and the second was made later, but the second app has files that I have copy+pasted over from the first app. Now, there are separate apps and projects. But I was wondering if there is a way to to have 1 project but with 2 apps in it and be able to build/compile them as separate apps? This is so that I wouldn't need to have multiple copies of the same Java code in 2 separate places. I want to have the second app dependent on the first one, so that if I were to make a change I wouldn't need to make a change in multiple places.
I've googled and search for my problem, but I get solutions for including/adding 3rd party libraries and dependencies (which I already know how to do), but that's not what I need.
EDIT: I would need them to generate 2 separate APK files.
Since you seem to not want to create your first project as a library, you could set up symbolic links from your second app to the source code of your first. They would remain two projects, and the second would link to the source code in the first.
Any shared code you changed in one, would be reflected in the other.
I'm assuming you are using Windows, so check this link out.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365680(v=vs.85).aspx
OSX Link: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man7/symlink.7.html
As requested. GIT can save the value of symbolic links. With some configuration it can follow them if that's what's needed. Also, you could use a branch in git to accomplish the separation of projects with a shared branch.
How does git handle symbolic links?
Links on branches:
https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches
http://git-scm.com/docs/git-branch

Checkout conflict with files. How do I proceed?

I just pulled some changes from a remote repository holding my teams project.
This is the message I received on pull:
Apparently, one of my partners made changed to the same file as me.
How do I proceed from here? The message is very vague. Was there an error? Do I have to undo what I did? Does he have to?
I faced this issue today and below solution works for me.
Do a git stash. This will consolidate all your local and conflicting changes.
Do a git pull now
Do you have uncommitted changes in the file that's in your working copy? Or is your working copy clean? The EGit documentation guides you thru the latter scenario.
In my experience, the error dialog posted by #lmray is what EGit shows when a local working copy has uncommitted changes. EGit wishes to merge in information from the remote but I'm told it will not modify a dirty working copy. To proceed, you must first commit your changes locally, giving you a fallback point, then request merge again. The merge should then produce a merged file, hopefully without any conflicts.
Thanks to #B. Dalton for trying to straighten me out - my dirty working copy file had uncommitted changes, and a local git wizard explained things.
Digression: this is a mental adjustment if you (like me) were used to working with SVN, which would happily pull remote changes into a dirty local working file. Not saying that was better, just that git works differently. I'm still struggling to convert my SVN-trained intuition over to suitable expectations for Git.
You must manually resolve the conflict by incorporating your partner's change into your code and committing the manually merged file.
Alternatively, if your changes aren't too complex, you may revert (throw away) your changes to that file, update your code to pick up your partner's changes, and then redo your work.
See http://wiki.eclipse.org/EGit/User_Guide#Manual_conflict_resolution
In Eclipse :-
Right click -> click on 'add to index'
Add conflict file in staged area
Right Click ->click on commit
Add conflict file in local repository
Pull
You will get all changes (change in remote repository and local repository)
Changes mentioned as Head(<<<<<< HEAD) is your change, Changes mentioned in branch(>>>>>>> branch) is other person change, you can update file accordingly.
Right click ->click on add to index
Right click -> commit and push

How to avoid no main class and no class def found error using DropBox and Eclipse for Java

I use Eclipse to write Java code and use DropBox to sync my code with others' across our multiple computers. Most of the time, everything works as expected: if anyone makes a change on either end, the change is saved and when the other person refreshes the Eclipse workspace, the changes come through and can be viewed and run successfully.
Sometimes, one of several errors arises. Sometimes Eclipse says it cannot find a main class and sometimes it says it could not find the class itself. Sometimes it will not report an error but for some reason will not actually update the .class file and therefore run an old version even though the compiler displays the new source code and that saves. I've then noticed that if I manually copy the code into a new .java file elsewhere in the file system and then compile it, it works fine, but for some reason it refuses to regenerate the .class file and I have to delete it manually and replace it with the one generated in the other project--then it works. But for solving the other problems everything needs to be manually copied, deleted, and re-pasted....
[The actual errors include NoClassDefFoundError, UnsupportedClassVersionError, and some other error related to not having a main class.]
I realize that the description here is somewhat vague, but unfortunately I'm not entirely sure what's going on. I hope I'm just missing some basic fact that would help solve all these problems.
Thanks!
I'm sure you will see issues using Dropbox for sharing your source.
Eclipse does not know what Dropbox is doing whilst it's uploading and downloading updates and their activities will certainly not be synchronised. At arbitrary points in time when Eclipse tries to do builds etc. it will find unexpected activity going on, maybe even partially downloaded source files which might explain the specific errors you are seeing.
You're trying to do something more complex than sharing photos or documents. The advice I would give is to use a source control system like git or subversion for source code sharing and control. You can then make use of plugins for Eclipse that are designed to integrate these systems in an easy to use way. There's a learning curve there, but the skills will serve you well.
You can use online versions of these solutions like github and unfuddle if you want to consume sharing, backup and version control of source as a service like you do with Dropbox. They're free, too.
Subversion, Git and all version control software solve all of these problems for you.
Dropbox is not really an adapted system for sharing code. What you should do is set up a SVN, and commit only the source files. This way, you won't have these kind of errors.
Dropbox does have versioning (you can restore old versions of a file), and doesn't seem to be a horrible solution for the problem. I keep my Eclipse repository on Dropbox so it is available on any computer; but since I only use it myself, I haven't encountered your problems.
There is one case I can absolutely see you running into problems--it's if your class files are stored in the dropbox as well. This would just screw everything up. Make sure you specify a location on your local hard-drive for all build artifacts (classes, jars, ...) and that the only thing on your dropbox is the .java sources.
In fact, I suggest you don't keep your eclipse project in your dropbox, just create your eclipse project and point it to the java files in your dropbox.
If this doesn't work for you, go with what other people here said and set up a SVN repository somewhere, it's easier than you would think.
Oh, another possible problem--dates! You may want to make sure the date on your java files isn't jumping forwards and backwards (as might happen if one of your developers were in another time zone). In this case, Eclipse may prefer not to re-compile your file.
Also, instead of the copy/etc procedure you are currently going through, try forcing a project clean.
Response to request for more info:
When you start Eclipse, select/create a workspace that is NOT on your dropbox. The best place is probably off your home directory. If you have already specified a default workspace, there should be a switch workspace item in the file menu.
Create your project. select "Create project from existing source" and specify the source files in your dropbox. I think you want "create separate folders for source and class files" to keep your class files out of your dropbox. If you see anything saying "Copy files into your workspace, say "no".
This should give you a valid, working project. I hope you don't see those problems any more.
One more thing may help--and this may work on your existing project--without the above procedure...
Whenever you refresh your files (f5) to load in changes from the dropbox, select the Project/clean menu and select the project. This should delete all the class files and rebuild them.
If your classfiles are shared on the dropbox, this could still have strange consequences on other people with eclipse open, so I really do suggest rebuilding your workspace as I said above.
How to avoid no main class
Provide one. That issue has nothing to do with DropBox

How to properly roll back to an older version in CVS HEAD using Eclipse?

I have a CVS repository in which I have a set of Eclipse Java projects where I need to roll HEAD back to the state it was at a specific time yesterday essentially abandoning all commits happened since said time.
I've tried different things, including using "Replace with another branch or version" which gives the proper sources, but where it appears that CVS now thinks I'm actually working "back in time" instead of in HEAD but with other sources which result in changed files showing up in Team Synchronize etc. Also commits tells me I'm working on a sticky tag and fails.
So, what is the proper way to tell Eclipse 3.5.1 that I need to rollback HEAD to yesterday?
I usually use the following for individual files:
Replace With -> History
Which can be found under the right click menu
Pick the version you want (it also includes eclipse locally saved versions)
Then commit to make it the HEAD
I ended up manually merging the files up in HEAD and very, very carefully checking in the sources. This was no fun.
Unless you have a tag in CVS, you will have to examine each file for this, and choose the version to revert to. (it is due to the way CVS stores changes, they are not file system snapshots like other SCMs).
You did a checkin in CVS with many files and after that you want to undo that?
My solution:
Mark the files (if no good checkin after the bad checkin you can mark all) --> Right click "Compare with" --> With Branch or Version --> Dates --> Add Date --> Take Date where you know the HEAD is ok --> Now you are in the Synchronize view, mark all files --> Replace --> Check in the files again
This will not really undo your CVS checkin (history) but you get with not too many clicks the old state. And you dont have to do it file for file.

Categories

Resources