MinecraftForge 1.8 Imports Not Working - java

I have recently started modding in Minecraft 1.8, with Eclipse. I created a test mod, and it worked perfectly. Then I decided to start a new mod from scratch.
Almost immediately, I got an error by my imports.
I tried pressing Ctrl+Shift+O, to organize my imports, and it just deleted them, because they couldn't be resolved. I tried going back to my previous project, and the imports weren't working there either.
After some playing around, I realized that other imports were working.
Only net.minecraftforge imports weren't working.
I am extremely confused as to why this is happening. If you need me to upload my code, I will gladly do so. I greatly appreciate your help in advance. Thank you.

When something goes askew with Eclipse when modding it's important to first check if the workspace is still good.
Sometimes for whatever reason a jar can get corrupted, deleted, locked by virusscanner, aliens kidnap it...
reason why isn't important unless you are into such a thing, but if you are solution minded first try to reset your workspace.
By running gradlew setupDecompWorkspace eclipse you redownload the stuff, re-decompile the jars and re-setup all the workspace items eclipse needs.
If your problem isn't solved after that you have a more serious issue.
Then I suggest you start really afresh.
Redownload the forge src from http://files.minecraftforge.net, extract it to a new directory and then run gradlew setupDecompWorkspace eclipse in that directory.
Then copy over your source files and see if the issue is resolved.
Then slowly add your dependencies/external jars.

Related

STS on MacOS Error: Cannot find main class (I've tried every solution I can find)

I'm relatively new to programming. I recently installed Spring Tool Suite (the only option I found for the Mac install was for a 64bit version) for Mac on my system, and after installing I created a test project using a java main class to sys out "hello world" to the console. Everything was going swell until I tried to compile and run the program. The console spat back out at me "Error: Cannot find the main class TestApp" (Test App was the name of my main class). I checked it for errors, found none. I thought originally that the project was bad, so I deleted it and created a new project with a similar name. This project returned the same error.
I did some research and found that occasionally the .metadata file for a workspace can be corrupted, so I tried deleting that file, and reopening an STS workspace from the folder to regenerate it. This didn't work, so I tried creating a new file and starting a workspace there, then importing my test project into the new workspace. This also returned the same error.
So then I thought maybe my build path had been corrupted, so I checked and it was pointing to the correct files. I verified that the compiler is working and compiling the run, as the generated bin folder had a binary file in the project had a file in it. I tried I tried deleting the run config and starting over. Still no luck.
I tried project=> Clean, then re-running, then tried deleting the .bin file and re-running, which compiled and created a new binary file, but still returned the same error in the console.
I tried an uninstall and reinstall of STS, deleted all of the folders for my workspaces, and created new folders.
I tried fiddling around in the project libraries to see if any dependencies were missing, and found nothing.
I tried starting a SpringBoot app to see if maybe running Maven for dependencies would help somehow?
Someone suggested it may be an issue with my machine being older, and sure it's old, but it's fully updated, has an i5 processor, 16 gigs ram, and a full TB of storage. I would be really surprised if that were the issue.
These were all of the solutions that I could find, and I may have tried a few other things that I can't remember (I've been at it for the whole day now).
Does anyone have an idea what may be going on here? I'm at that point where punching the computer seems like a possibility. If it is my machine, I know that using the Eclipse IDE with an STS plugin may be more lightweight, but I've heard that the plugin is also kind of a pain to work with. Currently I've just uninstalled STS again, and may try installing again if I can find a new solution to try.
After some further research I came across a way to reconfigure JRE's. I'm not 100% sure of what I did to fix it, but after a full reinstall and new repo folder, I went to configure JRE's when creating a project and set both options to v1.8 . It's working now!

Eclipse forgot all my projects?

That topic might have sounded a little silly, so forgive that, but here's what's happening:
I have several folder in my Package Explorer that contain several projects I've been working on.
The problem is that Eclipse seems to not find my projects within my folder.
Those folder-like icons are suppose to be double-clickable to reveal my projects...
But after I closed up last time, they won't show up again.
None of them!
And they're all there. In the Workspace I've always used. All the files, all the folders, all the everything.
Why can't Eclipse find them?
I've tried creating a new Workspace, as well as importing the old projects over again, but then I got the error that these projects already exist.
I've restarted Eclipse, restarted my computer and anything else I can think of restarting.
The biggest issue I have is that now I can't access any of my work, and thus can't keep working on it!
Could anyone be kind enough to take a stab at how I should go about fixing this?
Please, be gentle. I'm a little green to all this.
You can go into arcives in the top-left corner and click on projects to see if it's the correct project folder.
Another thing you can do is to check if the project-files are still in the folder where you have your workspace. If they are there it can help to create a "new" project with the same name and all the files will automaticlly be in the project again. :)

Eclipse won't generate import statements, stopped showing Quick Fix suggestions

My Eclipse installation suddenly stopped showing import suggestions. If I type a class name that isn't in the current package, autocomplete works fine and shows the class, but after picking from the drop-down, the class name is highlighted as an error with the message "MyClass cannot be resolved to a variable". This error shows no Quick Fix suggestions. However, if I manually add the relevant import statement at the top of the file, the code compiles and runs fine.
I've checked my build path and everything appears to be in order -- and like I said, the code runs when I hand-jam the import statement -- but losing automatic importing is really slowing me down. Any idea what could have gone wrong? It worked fine last week!
ETA: Another note, if it helps: F3 still opens the class declaration, so Eclipse clearly knows what I "mean", even without the import statement.
Also also: Things that have not helped:
Clean all projects
Restarting Eclipse
Restart computer
Delete .metadata from workspace, re-import project
Start new Java project, re-link source folder, re-add dependencies (not using Maven, but that's not my choice)
Thanks for all the help, everybody, but this turns out to have been a case of a broken Eclipse install.
I still haven't figured out exactly how or what was broken, but I tried to make a new project with a single "Hello World" class. The New Class wizard errored out with "Creation of element failed" in the class org.eclipse.wst.jsdt.internal.core.dom.rewrite.ImportRewriteAnalyzer. Once I hit "internal errors" in Eclipse, I gave up and installed a fresh Eclipse from a new download.
With a new Eclipse, I got my Quick Fix suggestions back, as well as automatic imports. I guess in future I'll try reinstalling Eclipse before I go looking for solutions to obscure errors like this :-/
These kind of situations can occur if your workspace went into a bad state or eclipse was unable to properly save state during last exit of workspace.
Try Project > Clean and clean all projects and rebuild all. See if this helps.
Clean all your projects. Then update Eclipse. Then restart of Eclipse. Then restart your development PC.
This happens to me sometimes too, I follow these steps and the problem always goes away.
If none of the other answers works, one brute force suggestion which sometimes resolves weird issues like this would be:
Close your Eclipse
Delete the .metadata folder inside your Workspace folder
Restart Eclipse
Note: This way you're going to lose all your workspace configuration. I advise you to backup it first in case it doesn't works.

R.java is missing on a clean Android Project

I'm creating a clean project on ADT and I noticed that the gen folder is empty (with no R.java in it), not letting me run the project. I'm running ADT with all stuff up-to-date (as you can see here)
I already cleaned and built it in every possible way. I also tried to reimport the project, and nothing. There are no errors in the XML files.
I searched for a solution and I found a lot of people with the same problem, and in most cases the solution was to update the SDK tools, but it didn't work for me.
Is there a reason for this?
at the top of screen, click build -> rebuild project
Give it a few seconds. it worked for me, i hope it save you aswell
im using Android Studio(beta) 0.8.9
My R disappeared after i fiddled with sound files in my res/raw directory(converted them to different formats, figuring out how SoundPool class works...and suddenly there is red "R"'s everywhere!
Try right clicking on the project, then going to Android Tools > Fix Project Properties.
If that doesn't work, then try cleaning it before and possibly after that.
If R.java disappears, you usually have to recreate the project from scratch again.
There are many reasons for R.java missing issue, i use to face this issue frequently, some of my thoughts to debug this issue.
Try creating another test project using File->New->Project->Android->Android Application Project. After creating the project run the project in emulator. If every thing works then your setup is perfect.
Check your imports section of your java files, some times default R.java gets included which is from android package. In this case Remove that import and add correct import statement.
Check your "res" folder all the xml's should be well formed and valid.
Hope these debugging steps may help to find the root cause.
try deleting the r.java file in gen folder. when you run again after cleaning and building the project. It should recreate those files and it should work after that. Try that.
Other wise you might have to reinstall Eclipse as you have tried in so many different projects
Something I just noticed was that after I removed the auto-generated code for the menus (which I wasn't using) it started causing errors. Eventually when I cleaned with the menu xml's still in the file structure, my R file disappeared. I removed all entries in the menu folder and then cleaned again. This worked for my specific instance. Hope this helps others as well.

Cannot convert project... Premature end of file error in Intellij IDE

I am using Intellij IDEA as an IDE for running Java programs. Dues to power fluctuation computer got restarted. Now when I launch the IDE after reboot i am getting the error Cannot convert project: /home/aniket/IdeaProjects/JavaDemoCodes/.idea/workspace.xml: Error on line -1: Premature end of file.
Has anyone encountered this situation before? What can I do to view my project back again?
I also had this after a power failure, I simply deleted the workspace.xml file from the projects .idea folder, restarted IntelliJ and it seemed to be OK apart from loosing which files were open.
Cheers,
Nick
I had this exact error when my laptop bluescreened. I solved it by:
Exit IntelliJ IDEA
Rename .idea folder
Start IntelliJ IDEA
Create new project from existing sources
Exit IntelliJ IDEA
Copy all files from old .idea folder to newly created one.
Restart IntelliJ IDEA
Finally solved the problem. Hers is the solution. First of all I had two Intellij IDEA projects open in two separate windows.
One was the project which had corresponding subversion repository. This was a file-based format project. Files that define a project are .iws, .ipr and .iml. .iws is the one corresponding to the workspace configuration. I just reverted back this file with svn revert project.iws and I could launch my project again.
But the problem in second project JavaDemoCodes still persisted as it was custom project I created and it looks by default we get a directory-based format project instead of file-based format project. This has all its configurations in /home/aniket/.IdeaIC12 directory. As many of you suggested i searched for workspace.xml here but could not find it. I tried find . -name *.xml but i still could not find it(Also as the error suggests there is no file /home/aniket/IdeaProjects/JavaDemoCodes/.idea/workspace.xml ).Finally I did import project from my first project(the one with svn repo) it detected my JavaDemoCodes project as Intellij IDEA project and let me open it in new window.
Not sure if this is the perfect answer but it solved my problem and yes as someone suggested I deleted .iws file from my 1st svn repo based project and tried to restart but was of no help. New .iws file was created but it still gave me the same error.
I have experienced this same problem. It happens to me when I have IntelliJ open and for whatever reason (usually problems with having multiple VPN connections open), my computer freezes and I have to do a forced re-boot.
My solution is to use Windows 7 restore. I'll go to the folder it is complaining about, right click on it, and do a restore. If I'm lucky, I have a restore point only a few days old.
For me, rebuilding my configuration on several projects from scratch is too time consuming. Using a restore point from a few days or even a week makes more sense.
Good luck.
I solved it just by creating a new project, then starting it and then reopening the old project..

Categories