Files edited outside the ide - java

If I run a script to edit files outside of the ide I am using, will the ide recognize the changes made to the files?
More specifically:
-IDE: Netbeans 6.8
-Version Control: CVS
-OS: Windows XP

In general, yes. But the form designer of NetBeans considers some parts of the code "private", and you shouldn't modify these parts externally. They are identified by comments in the generated code:
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
These parts are in fact generated from an external proprietary .form file, and having the source code not aligned with the .form code will mess everything up.

Yes it should. Give it a whirl and check it out.

Yes, with some caveats:
If you have those files open, edited, and unsaved in the IDE at the time, then you will need to tell the IDE whether to discard or keep your in-IDE changes.
If you have them open and unedited, then depending on the IDE, you may have to tell it to reload those files (the IDE should warn you that the file has changed since you last opened it).
If you move files around, and your IDE has some kind of project file (that tells it, among other things, where all the files are) and you don't update it accordingly, you may have problems.
Any files that you don't already have open in your IDE should behave as expected, and I would consider it a bug if it didn't pick up the changes.

Related

Eclispe project "locked"

I have been working on a struts project for a month now, with the IDE Eclipse JEE. So far, everything was good, but this afternoon it decided not to update my project anymore.
Before that, after modifying something, I went on my project, right click, Export and then I exported the whole project into a war file and copied the result in the proper directory on the server machine.
Now, even if I updated one of the java files, nothing changes between one update and another. I even tried to completely erase the content of a file (the one that manages the user login), exported it into a war file and the website was still functional.
The weird part is that if I modify a non java file (ex a JSP file) the modifications work and I can see the difference on the website.
My theory is that Eclipse caches the java files to accelerate the compilation, so that if a file was not modified it does not have to entirely compile it again. But for some reason it is completely broken.
Some more details about the problem: even if I intentionally write something wrong in a file and save it, the red marker that should appear next to the file name is not there (same for the yellow marker for the warnings). I also have a weird red exclamation point on my project name and I don't think that it was there before.
So, does anyone knows what is going on ? Did I accidentally lock my project ? I tried to relaunch eclipse, close and reopen the project, delete and recreate it, I even reinstalled Eclipse but nothing works.
Ok I figured it out.
Turns out that one of the libraries I set in the build path was missing (don't ask me why, the JAR is still there but whatever). After removing it from the build path (as I was not using it anyway), everything works fine again.

Why does my .java file disable errorchecking?

Recently I've added a .java file to my Processing Project (its called GClip.java from a library which is called G4P). That .java file helps to copy stuff to the clipboard. I read that on a forum, however directly after I created a new Tab and imported the content from the .java file it gave me that message:
sketch_190108b contains .java tabs. Some editor features (like
completion and error checking) will be disabled.
Now I can't see errors and stuff. How can I turn it back on? I've already tried turning it on in the preferences tab but it didn't work... Any help please?
My guess is this is because the error checking comes from the Processing preprocessor, which turns Processing code into Java code. If you're using a .java file, then the prepocessor is skipped, so it can't do its error checking.
If you want to be sure, you could search for the message in the Processing source code here.
You might consider using a Java IDE like Eclipse or Intellij if this is important to you.
Also, please make sure you're following the G4P copyright license when you copy its code.

IntelliJ IDEA - Decompiling/Editing/Recompiling JAR

I realize this may seem like a completely stupid question and this question is a "wall of text", but I'm feeling like I've gotten way out of my depth here and need some guidance. I've read several SO questions on this topic, but still can't seem to find one that addresses this particular situation. (please reference update(s) at the end of this post)
BACKGROUND
Our company has an application that was built in Java and released as an executable JAR package by a developer who passed away a couple of years ago. Since then, there has been minimal need for even looking at that code, let alone making any changes. That's been really good because I do my programming in VB.NET (Visual Studio) and, while I can read and make sense of Java code, I'm not proficient in actually writing/debugging that code.
However, a recent issue has come up that forced me to try to take a look at this Java code due to some internal changes in organization and data structure. I've looked in his "src\" directory and found older versions of his original code but wasn't able to find the most recent version anywhere. I found some code that made it possible for me to extract the JAR that's currently being used to a local directory on CodeProject (JarsVB), so I've been able to look over some of the .java files when trying to figure out what query is being used for some random operation. I don't know what tool(s) the original developer used to create the project/JAR, so I've installed the IntelliJ IDEA Community Edition 2018 as an IDE, and it's worked for me so far to simply view the code so I can understand a bit about what it's doing.
PROBLEM/GOALS
Unfortunately, now there is a need for me to make a change to the Java code and update the JAR, and this is where I can't seem to make heads or tails of what I need to do. I have my local copy of the code from the "unzipped" JAR containing all the .java and .class files (along with all the other resources), but I'm not sure how to go from that to modifying the code and recompiling the executable JAR.
So, my goals here are as follows:
(properly) Decompile the existing executable JAR. (If the JarsVB solution I mentioned above did what it was supposed to do, I should already have this part handled, but if there's a better, more "integrated" way of doing it, I'd be open to that as well.)
Modify one or more .java files. (I believe I can figure out the syntax well enough to get this part done.)
Debug/test my changes.
Recompile the changes into an updated executable JAR for release. (THIS is where I'm experiencing the most confusion.)
WHAT I'VE DONE
I've been looking at the documentation for IntelliJ to try to figure out how to make this all happen, but I feel like I'm missing stuff. I set my "Project Structure" settings to point to a specific folder, but I can't seem to get it to actually build anything in my specified path.
I went into one of the .java files and made/saved a small change to test, then went to the Build menu and tried all the building options available to me: "Build Project", "Build Module", and "Rebuild Project". Each time, the event log shows that "All files are up-to-date" (even though I changed one), so I go to my output directory to see what it built, but the folder is empty.
I looked at the IntelliJ documentation for Packaging a Module into a JAR File, which says to
On the main menu, choose Build | Build Artifact
But that option is disabled in my Build menu, and when I look in the Project Structure dialog, the Artifacts section is empty, so I try to add a new setting (Add -> JAR -> From modules with dependencies...), but I'm not sure how to properly set that up either.
I tried to select a Main Class from my classes/ directory, but it wouldn't actually accept any of the .class files I selected, so I just left it blank. Then, I did a search for a MANIFEST file, but couldn't find one anywhere so I left that blank as well. The Build menu option is enabled now, but when I tried to Build Artifact, again, I get nothing in my output directory. In fact, the only files I can find that have changed are in my local working directory. I'm just dumbfounded at this point.
FINAL THOUGHTS/QUESTIONS
I've tried to provide as much detail here as I could think of about all the things I've tried and gone through to get this JAR updated, but if there's a question about anything, please let me know. I'm not looking for a "handout" and I don't expect anyone to do this for me, but I'm also not wanting to become a Java developer just for the sake of making some minor changes to an application that will eventually be replaced by a .NET application. I simply am not familiar enough with the tools or Java development in general to know how to get to where I want to be from where I am.
My decompiled source files are in a totally separate directory from the original, production JAR file because, when I recompile this time, I want to completely recreate the JAR. Am I understanding the Java development process correctly in editing one of the .java files I got from decompiling with the JarsVB and then recompiling the JAR?
Thanks in advance for any assistance in finding the resources I need to accomplish these goals.
EDIT/UPDATE
So, looking at the link in the accepted answer in another SO question, How to build jars from IntelliJ properly?, I figured out at least one part of my issue: Leaving the Main Class setting of my Artifacts configuration blank was a problem. Since I hadn't been able to select a .class file and I wasn't sure how to correctly populate that field, I hadn't given the IDE enough information to operate correctly. I entered the namespace and class (namespace.class) I found in the class file that apparently defines the main method for the application, then set the path for the MANIFISET.MF file to my output directory and tried again to Build Artifact.
This time, at least, it DID produce a JAR in my defined output directory, but it's only 1KB in size. As stated above, the source files are in a completely separate directory from the original JAR file from which they were decompiled. The output directory, too, is completely separate from the location of the original JAR file. Do I need a copy of the original JAR file in the output path for recompiling to work correctly?
I'm making progress, but I'm sure I'm overlooking something "stupid" at this point that's primarily due to my unfamiliarity with the IDE and developing Java applications in general.
UPDATE 2
Looking at another SO question - how to create jar of java package in intelliJ idea - I learned that I have to individually add the necessary files for repackaging into the JAR. However, this brings up the question, what files do I add? The linked question identifies the .class files, but when I go look at the .class files in my working directory, none of those have been updated recently, so it looks like I'm still missing a step somewhere.
Another question this brings up is, are there certain conventions for Java development of which I need to be aware when preparing my environment? I have my output path set to a completely separate folder than any working or production code, so I'm wondering if something in that setup might potentially cause issues.
As I said before, I made a small change to one of the .java files, then tried both the Build Module and Rebuild Project options, but those are still telling me that "All files are up-to-date". Even so, I tried adding just the .class files from under my classes\ directory to my Artifact configuration and tried again to Build Artifact. I got a bit larger file (approx. 5MB), but when I try to execute the JAR, it just doesn't appear to do anything, let alone actually launch the application.
I tried again by adding the root folder of my local copy of the source adding everything the root folder contains. (yes, the directory probably needs some "spring cleaning", but that's for another day)
This time, I got a much larger file this time (approx. 21MB), so I thought I might have fixed the problem. Unfortunately, no such luck. The JAR still doesn't appear to execute.
For reference, the original JAR file from which the code was decompiled is approx. 59MB in size so, either IntelliJ is doing an incredible job with compression, or there's yet another step I haven't yet found. I'm sure this is all a matter of getting my IDE configured correctly, but I just can't seem to find the right combination of settings.

eclipse errors exist in required projects but editor shows no errors

I use eclipse to code in java. My code was running perfectly fine. Finally, i deleted some files which were not needed from my drive.
Right now, I have the source file and the compiled .class files in the correct folders. Also, although I initially had multiple .java files, I am 100% sure that the one I need is there and also that it doesn't need anything from any other thing. All the imports (i import only from standard libraries) are showing no error.
The problem is that when i make any changes in my .java file, and save it, it does get saved but when I execute the code, it runs just like the old version, i.e. the changes are not reflected in the output. Also, on clicking 'run', eclipse gives a warning that 'errors exist in required projects' although the editor shows none.
Whats going wrong ? Please help.
Okay got it....I had added some external jars to my project. Later, when I realised that they were not needed anymore, i deleted them from my hard disk. However, the build path contained their names too among the other libraries (and displayed "missing" after that). I removed them and its working fine.

Eclipse CVS ignores .class files -- how can I turn that off?

I would like to commit new .class files into CVS via Eclipse, but these files get ignored, and I'm not sure where to turn that off. The Preferences windows a section for doing this, but .class isn't listed.
Preferences > Team > Ignored Resources
Also, change to the Resources Perspective to see all files.
First of all I'd like to echo the sentiment of the other answers, in that checking the compiled source files into source control is a very bad idea, as it means any time someone makes a change to the source, they'll have to remember to checkin the corresponding class file.
Regarding your specific question, this page states that all generated .class files are automatically marked as derived, meaning they won't be checked in automatically:
Any resource marked as derived will be automatically ignored for version management by Team CVS. Some builders, such as the Java builder, mark all of its build output (e.g. .class files) as derived.
To my knowledge there no way of changing this, which should underline that this is a bad idea.
I ended up figuring it out... it's a little odd: You have to go into the Preferences window (Team -> Ignored Resources) and add ".class" as an ignored resource, then uncheck the check box.
Are you really sure you want to be checking compiled files into CVS? I've never worked on a project that does this - it is a bad practice.
You should only really store source code in CVS, not the files generated from the source code. There is no true need to check these in because they can be re-generated from source code at any point in time.
By checking in the output of your source code, you're only going to introduce the possibility of headaches due to someone forgetting to check a .class file in, etc.
If anyone is still interested, although I absolutely agree it is a bad practice to check .class files into CVS, sometimes I think it is reasonable.
For example, in my case I have an application that contains an EJB 3.1 which has to be called by an external agent (ControlM). As the EJB is called by a remote process the generated stub (.class) is needed. In this situation, I checked this generated stub class into the CVS because I want it avaliable for all the team members.
What I do is the following:
Open the Navigator View. (In this view all .class can be viewed by
default)
Select the .class / right click / Team / Add to Version Control
Accept the warning saying that you are going to add ignored
resources
Now the .class can be committed as usual.

Categories

Resources