IntelliJ Not Saving Changes - java

I've been encountering an issue with IntelliJ. Every time I save a change to some FXML I'm editing, the changes are removed upon executing the program.
For instance, I will change the 50.0 above into 160.0, and once I run the program the code changes back to 50.0. I've also attached a picture of the project explorer as it may suggest something with Verison Control.
Evidently some of the colors are not as normal. I imported the project from a Gradle off of a shared GitHub Repo. Thanks!

You are in the build folder which contains generated files.
You changed that file, but then it was overwritten. You need to identify the source file and to make that change there if you want to have something persistent.

Running IntelliJ from C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.1\bin: idea64.exe worked for me. Now files are being saved and it's not throwing this error. Navigate to your IntelliJ bin directory above and run IntelliJ from the executable. You may need to regenerate your short cut file to IntelliJ.

Related

Eclipse not recognizing changes in code

A friend and I are working on a java project in Eclipse. Whenever we "ship" a new version we export it to a runnable jar.
It seems whenever we try to send the file back and forth (over google drive) to work on separate parts of it something gets messed up. This doesn't happen for him, but when I download the file from Google Drive, Eclipse does not recognize any change I make to the src.
It doesn't matter how many times I change the workspace, move/ rename the file, clean/ build the project. Nothing seems to be solving this problem. Any advice on why this is happening and how to fix it?
It would be infinitely better for the both of you if you looked into some kind of source control system, as opposed to a file sent through a file sharing service.
Sharing the source code in a JAR doesn't allow you to:
Keep a revision of known working code, in case something breaks
Reliably import the code
Keep track of changes (who did what to what file, etc)
Look into something that's suitable for sharing between users. GitHub and BitBucket both offer free Git hosting, which is a very popular source versioning tool.
Eclipse is probably building the new version of the runnable JAR in the project's output directory, which by default is something like %PROJECTDIR%/target. The new version of the JAR with your changes will be there, and you'll have to export them again to trade files back again. See also: How do I change a Java project's bin folder in Eclipse?
it is probably because it is not updating yours .class, try delete .class of "target" folder of your project, make clean (project - clean) and save again the changes
There are many steps where you can solved it,
Clean Project and Re-Build
Remove .metaData and .settings from Workspace
Clear cache
In my case, I have tried much more and I got to resolve it by removing Classes, test-classes folders if Its there in Target folder

How to run a modified java program in eclipse?

I have a project in Java which get a file using smb client. When I edit this code and run it again in Eclipse, it is not running my modified code but running the same old one.
Checklist:
I saved the file and made sure there are no write errors.
Build Automatically is enabled.
Run configuration is configured properly.
There are no unresolved errors.
what am i doing wrong?
To find out whether Eclipse has really compiled your code, have a look into the bin/ folder of the project and check the date of the .class files in there. You will have to do this outside of Eclipse since it hides the content of this folder by default.
Use "Clean Project" to force a rebuild.
If that looks correct, the next step is to go to the Debug Perspective. Open the Properties Dialog for the process. Eclipse will then show you the classpath that it used to start the process. Make sure the paths are correct.
Delete bin folder data and clean project. To clean project:
Go on Project-->Clean-->select your project-->clean-->build project
This will solve your problem, if this does not work, please write a Hello world program and check this works or not. If this is also not working, check your Eclipse

intelliJ not freshing file

I have a Spring Maven based project, its running fine. I just updated my svn from directly right click > Update. Now I have new files in my folder but in intelliJ IDE its still showing the old files.
How can I refresh my project in intelliJ so it have the latest files from folder.
I am using intelliJ 12 ultimate edition.
You can do Synchronize from the project window, but you shouldn't need to. I would check the old copies are not in a different place to where you expect. Try using the (><) button in the project windows to see where they come from.
Make sure all the files are local and there are no symlinks. If you are using remote file system or symlinks, deleting bin/fsnotifier binary can help. In any case it's a bug that should be reported.

Eclipse using wrong build while debugging

I am new to eclipse and java. The way I understand the directory structure is that you have source packages in src/ folder and they are built into the /build folder.
It was all working fine until recently. But today I tried debugging after creating a new class and it was throwing ClassNotFoundException when I do F11. On investigation, I found that it was using older versions of even the existing classes and not the new builds, and there was no .class file corresponding to my new class. I checked the build/ directory and it seems the builds are also old as it is showing yesterdays last modified time despite the fact that I have made changes today and tried to debug it. This problem is not limited to debugging as I exported the class into a jar file and it is still using yesterday's jar file. What could be the issue here? Is it not 'building' the classes? Have I messed up the default 'build' folder somewhere?
First you should check, that the "build automatically" feature is activated (menu "Project/Build automatically").
Next you should do a refresh of your whole project to tell eclipse to check for file changes that occured outside of the eclipse IDE.
If all that doesn't help, do a "Project/Clean.../clean all projects" inside eclipse.
I'd stop assuming and find out where Eclipse is putting your newer .class files. They can't be disappearing. Once you know that, compare it to the project set up you have and make sure that you know exactly where the .class files are going.

Eclipse does not refresh project files in package explorer view

Today I see a strange behaviour of Eclipse 3.5.2 for the first time in 3 months.
First, when I run a main function, it runs a previously compiled version. Let's say I press Ctrl+F11 in the window with an open java class and existing main function. Usually it rebuilds the class and runs a new version. Today even if there was a compile mistake, it would run fine. So I guess it does not recompile the class.
Next, more strangely, if I intentionally make a mistake in the code and Eclipse underlines those lines in red, still the project Explorer does not mark them as containing errors. They remain of grey color if there were not any errors.
First I did not know how to solve this problem. I tried to reopen the project, restart Eclipse and finally reboot the OS. After the tenth attempt, after rebooting, Eclipse said that all project's files are "OUT OF SYNC with the file system". When I pressed "Refresh" - F5 on a project's header name in Project Explorer it finally marked all the files with errors as containing errors and running the main function gave the desired result.
An hour of my work passed and this happened again , with the other project. All the same. No marking of files as red, running no matter what old version of class with no compile errors.
And since Eclipse does not tell that files are out of sync, simply pressing F5 on a project cannot help.
What can you suggest?
When you select a project in the Project Explorer view and press F5, Eclipse should traverse the entire directory tree for the project checking that all files and directories all in sync. It does for me ...
The only thing I can think of that would cause this not to work is if you have file system timestamp anomalies. For example, if a file in the file system is updated but the file's last-modified shows that it was updated in the past. This kind of thing can happen if your machine's system clock is moved backwards or forwards at an inconvenient time. If you think this might have happened, try closing all projects, restarting Eclipse and doing another F5 refresh.
(I used to run into Eclipse synchronization issues a lot, but I put that down to a combination of flakey plugins and doing builds from the command line. Either F5 or Project>Clean usually works for me.)
It is also worth checking that you haven't turned off "Build automatically"; see https://stackoverflow.com/a/2818290/139985. This is not a "refresh" problem, but it would be easy to confuse it with one.
Is Build automatically on? (Menu > Project > Build automatically)
It happened to me because there was a cyclic dependency between two projects. Each project had the other on its build path.
Solution: Reimport the project
It happened to me when checking out a new file from svn in explorer. Eclipse could not find the new file for some reason.
I tried refreshing the project(F5) and Project > Clean and build the project(Project > Build All) none of these worked for me.
So I deleted the project from the Project Explorer view(Not from hard disk). Make sure you unselect "Delete project contents on disk(cannot be undone)" checkbox and save any unsaved changes before you do this.
Now reimport the project using File > Import option. That should work in most cases.
If you use gradle, or something similar, instead of reimporting a project you can just regenerate the project files (gradle eclipse for example), and then you can refresh the project. Less cumbersome than deleting and reimporting.

Categories