I'm brand new to IntelliJ but have been working with java for years. In IntelliJ IDEA 12.1.6, when I first create a .java file and then compile it, the .class file with the same name appears in the 'out/production' folder just as its supposed to. But if I do anything to the java file to get a compile error, the class file disappears from the folder. Is this some weird setting in IntelliJ? Do I have a bad installation?
This is because IntelliJ is rebuilding automatically when you change the file. To avoid having the files deleted, go to the Compiler section in the Properties (Cmd+, [Mac] Ctrl+Alt+S [Win]) and uncheck the "Clear output directory on rebuild".
Related
So, I deleted a couple of .java files from within eclipse because I didn't need them anymore. However for some reason another class still uses them and compiles without a problem. When I go to the declaration of the constructor of one of the deleted classes a .class file opens of that class even though I thought they got deleted by eclipse when I deleted their .java files.
I have tried to clean the project and I tried to find the .class file using the system file explorer in the folders that are listed in
project > properties > resource > linked resources. However I couldn't find them.
Now, since I deleted those files/classes there should be a compile time error wherever they are used but everything compiles without an error, even using the code that should've gotten deleted. A colleague that recently joined the project does receive compile time errors, since he doesn't have those class files. And I want to get them too, so I can fix the code where the classes were used. Of course he could show me the lines of code that are affected but if this happens again he would probably be affected as well as he would have the class files by then.
Try doing the following
Go to project > properties > Java Build path >Source
under that you can find Default Output Folder section, simply delete the classes folder under that location with in your project.
Try cleaning the project.
Or
Simply close the eclipse and reopen it again, sometime this would work for me.
Hope it resolves your problem
If you just deleted the sources, they binaries would still be there. So open the Navigator View and go to the project in question. Look for the bin directory and delete the appropriate class files. Otherwise, delete the project itself.
You should also ensure that no other programs depend on those class files.
I found the problem. Someone built a .jar file I didn't know of which contained a lot of old code.
I found it by right clicking the constructor and selecting
references>project
My eclipse seems to be pretty screwed on my laptop. Whenever I load a program up from College, it does not detect the errors or anything. Also now when I attempt to run the program, it won't allow it; i'm given the message
unable to find an ant file to run
Anyone able to help me out?
1-Create a new project in Eclipse
2-After the project is created, look in the package explorer window pane on the left and right click on the src folder.
3-There are two methods for the next step, you could either add a New > Class, and then copy and paste everything from your old java file to the new class (make sure the class name is the same), or the better route would be to Import.
4-After clicking Import, select File System under the general folder. Click Next.
5-Browse for the java folder where your source files are located. Once you click ok, it will add all of the source files to the right pane.
6-Select which files you want to add and click Finish.
7-Now if you look at your Package Explorer window you should see the source files. Now just
compile them, and the error shouldn't appear and you can run them just like before.
By creating the new project, you're making sure Eclipse knows where your source files are located (in ./src) so that it can compile your code in that location.
I've been using eclipse a very long time but I've never encountered this problem.
I have a program I'm working with, and normally to navigate between class files you can simply double click the class file under the project explorer, or you can right click and select open with java editor.
This is fine, but randomly, I have a single class file that when you try to do this, nothing happens. If you select open with text editor, the file opens, but it won't open in java editor. Anyone experienced this?
I fixed it by copying the class file. The duplicate opened normally. Thank God.
Q: You have an Eclipse Java project (or J2EE project), correct?
Q: Most of the .java files in your project open with the (context-sensitive) Java editor, correct? And most of the .class files already compiled in your project open with the "Java decompiler", showing the Java byte code instructions for that class, correct?
Q: The problem is that some of the .java (source) and .class (byte code) files don't behave this way, correct? When a file goes "bad", is it always broken for both .java and the corresponding .class file?
SUGGESTION: Try Project, Clean; then "Project validate". See if one or all of the affected files "recover".
Close your eclipse IDE and compile the project from terminal or CMD using mvn clean install -U -DskipTests=true.See if you get any error in compilation then fix it(usually it is due to some indentation error which by mistake got added in java file),if not just lauch your eclipse IDE and open the corrupt java file ,it should open this time without any issue.
I have a Java JAR file that was developed to run in the browser. It works fine. There doesn't appear to be any sort of build file associated with the source code I've been given and I'm attempting to create a project and/or build script.
The source code references some third party code. What I've done is unzipped the JAR file into a folder that has this structure:
\App\src\com
\App\src\META-INF
\App\src\applet
The "com" folder contains subfolders which contain the .CLASS files for the third party libraries. "applet" contains the .JAVA source code files (one folder, maybe 15 files).
The code appears to be written in 1.4 syntax (I manually attempted to compile some of the .JAVA files and it complained that some things were deprecated and/or required the older version).
I created a Java Project in Eclipse and pointed it to the \App folder. Then I went into the Properties for the project and went to Libraries and and clicked on "Add Class Folder" and added the \App\src\com folder. Then I went to "Order and Export" and moved this to the top. I also set the Java Compiler version to 1.4.
I am getting a large number of compiler errors, all of which seem to stem from the fact that it says it can't resolve an import. This import is the set of .CLASS files contained in the "com" subfolders. The namespace matches the directory structure.
This seems like it should be really straightforward, but I've tried various things and don't seem to be making any progress. Based on what I've read I'm sure it has something to do with the pathing but I'm at a loss at this point on how to fix it.
(I'm sure it goes without saying that I'm not a Java dev.)
Any thoughts or ideas as to where I'm going wrong?
Can you please try to right click on Eclipse's Navigator. Select Import>General>archive file> (Jar file that you want to import).
You should be getting the jar file correctly imported at this point. Do tell me if you face any problems.
I have a problem while runing my application in eclipse. I make some edits like this:
String res = "newvalue";
System.out.println(res);
But when I run the application I still receive "oldvalue" in output. After this I tried to delete main() function - and I run application and I see "oldvalue" in output again.
Maybe it's some cache in JVM, or smth. else?
UPD:
It's 15:35 on my clock now. But in /bin folder I see .class files with 14:33 timestamp. I change source files (.java), press ctrl+f11 in eclipse and files in /bin folder are still 14:33 ...
UPD2:
After cleaning the project I receive the following problem:
The project was not built due to "Could not write file: D:\projects\NelderMead\bin\ru.". Fix the problem, then try refreshing this project and building it since it may be inconsistent
SOLUTION
The problem was that eclipse can't write file to the folder with spaces and UTF chars in it's name. So, I copy project to the new clean workspace and it runs without problems! Thx all for help detecting the problem!
You're executing an older class files, the reason could be
a compile error somewhere else (see problems view)
or your changed accidentally the source path so that the new source no longer gets compiled.
Try to clean the project and make sure the new classes are compiled to your output folder.
The JVM doesn't have a cache for class files.
First, make sure the file is saved (there is no asterisk next to the file name in the tab). Usually files are saved automatically, but you could choose not to save files and never ask by mistake, the first time Eclipse pops up this dialog.
Then see what's going on in the Problems view. You might see something like project cannot be built due to the following reason. It may be because of compilation errors in the dependent projects.