Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Find & Replace?(Looking for a way to change two lines of code quickly.)
Find & Replace? [message #1791751] Wed, 04 July 2018 19:16 Go to next message
Michael Jandrew is currently offline Michael JandrewFriend
Messages: 1
Registered: July 2018
Junior Member
I am new to java all together and am working on a research project using Eclipse. Our programmer was unable to finish coding our project because he had to work on other research. There are a few clunky workarounds but everything works.

The worst of the workarounds is having to do this:

Open the "filename.java" file under the "filename" folder within the "src" folder tree by double-clicking it.

Once the file opens in the window you will change the code in line 6 from "FILENAME_TRIAL_1="Trial1.xml.log"' to "FILENAME_TRIAL_1="Trial2.xml.log"'

and the code in line 7 from "FILENAME_TRIAL_2="Trial2.xml.log"' to "FILENAME_TRIAL_2="Trial1.xml.log"' and hit the "Save" button.

A friend of mine works with some scripting software so he volunteered to help me if any solutions are over my head.

I see this as something like a find and replace function but I do not know how to do that without cycling back and forth for that function without using CTRL + F. I would like to know if there is something that can be run to do the functions for me simultaneously.

Thank you in advance for your help!
Re: Find & Replace? [message #1792238 is a reply to message #1791751] Fri, 13 July 2018 06:19 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 62
Registered: March 2018
Member
I have no idea what "line 6" and "line 7" are. Your programmer seems to be using an xml plug-in for Eclipse, so you probably need to hunt up some tutorials to learn the basics of how to run it.
That being said, the general kind of thing you are doing is something I often do when moving from one working version of a java project to another version that I am going to change a lot. I keep the old copy intact so that when the new version blows up I can just go back to the old one, make another copy of it, and *rename* appropriate components thereof.

If I had a project called Photo-carousel_1, I would have gone through several generations of minor changes by copying the project and pasting it into the same general area in the "Package Explorer" (along the left side of the basic Eclipse screen. When I did that I would automatically get a new project called "Photo-carousel_2. This part of the process is quite superficial. I could have gone into my computer's directory or folder where I already had Photo-carousel_1, and then copied it, changed the name, just as one might duplicate any folder. However, when I went back to Eclipse I wouldn't see the second file until I had used "import" and found that file and directed that it be imported into my workspace. So it's a lot easy to do everything from within Eclipse.

Lately I've noticed that when I want to track down a specific version of P-carousel.java, I have to do a lot of detective work since every time I copy a project and get an incremental improvement version_2, I've kept the same old java file file name. So if I search for P-carousel.java from outside Eclipse I am finding dozens of files with the same name but different dates of creation. Sometimes even the dates of creation are not clear. So it would be better if I could have a P-carousel_1,java, a P-carousel_2.java, and so on.

If I were to go into the file structure of my computer and change the most recent P-carousel.java to P-carousel2.java, and then when back inside Eclipse and tried to work with that new project, I would find that an error was kicked up. Why? Because the class name used in P-carousel2.java cannot be P-carousel(). Simply changing that by opening and editing that java file won't be all I have to do because "P-carousel" may get used several times, and I'd better be able to get them all changed throughout my whole project wherever the name occurs. It's not only a pain to do that, but I might miss one and have an error that would take me a long time to discover because I would glance right over a reference to the old class name.

Therefore, for what I have to do, I should let the computer do the checking for me. I go to source/defaultpackage/P-carousel, hilight that "P-carousel" mention, go to Refactor, and then select "rename" in the drop-down. Eclipse will go through and change everything that needs to be changed.

I suspect that the same general method should work for you, although I am puzzled as to why you make the double swap changes you've described. Not having my stuff set up like yours I have no way of checking out my idea.

Your original programmer should be able to tell you exactly how to do this in a minute or two. You can probably find a tutorial on-line by googling for something like:
Eclipse java swap log file names or use "change," "exchange," "filename log file swap" ... I don't know for sure. Sometimes it takes me a long time to guess the right question to ask when using Google.

[Updated on: Fri, 13 July 2018 18:01]

Report message to a moderator

Previous Topic:org.eclipse.core.contenttype: Could not create content describe
Next Topic:SVN Checked Out Maven Project can't run JUnit Tests
Goto Forum:
  


Current Time: Tue Sep 25 14:34:53 GMT 2018

Powered by FUDForum. Page generated in 0.03251 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top