Why can't I make this minecraft mod? - java

I am currently following this tutorial on how to make a Minecraft mod. I have done everything that he has done, but when I open Eclipse and try to open the Minecraft project it give me an error saying:
'Open Project' has encountered a problem.
The project description file(.project) for 'Minecraft' is
missing. This file contains important information about
the project. The project will not function properly until
this file is restored.
How can I fix this error so I can make my mod?
Edit: Here is the errors that I am having...

You need to execute the command:
gradlew setupDecompWorkspace eclipse
from the commandline before you can use eclipse.
go to your start menu
type in cmd
then navigate in the command prompt to your folder where you extracted the mdk
then execute in that folder the abovementioned command.
Then open eclipse and point it to the working directory(eclipse in the mdk folder)

I'm not familiar with modding Minecraft, but from the information you've provided there are a few possible solutions. First you need to check if the .project file actually exists or if it is really missing. Go to the workspace folder as per the video and it should be in the root folder of the project in there.
If it does exist check that you have selected the correct folder for your workspace and the project. If these are wrong Eclipse might not know where to look to find the .project file.
If it does not exist you will need to create one in order to load the project. The easiest way to do this is:
Open Eclipse at the workspace specified in the video. I'm assuming here that you have already downloaded and extracted everything. I think the workspace is a folder named eclipse
Create a new project (File->New->Project). Don't try to open the broken project.
Navigate to the workspace in windows explorer. In here you will see a folder for the broken project and one for the new one you have just created.
Open the folder for the broken project and copy the entire contents.
Go back and open the folder for the new project. Paste everything here. Some things may be overwritten but there shouldn't be anything that causes a problem.
Go back to Eclipse and refresh the new project (Right click on project in left pane->Refresh)
You may want to rename the new project to have the same name as the old project. If you want to do that you'll have to delete the broken project.

Did you move the anything in the Eclipse project folder after creating it?
I used to teach modding to kids and this was the most common error. If you start moving things around without right-click -> Refactor -> Move then Eclipse will become confused and could cause this error.
Another error I'd often run into is if the kid was using a parent's machine and they did not have administrative permissions OR if the internet connection was particularly slow. This caused certain files to be lost when downloaded during those cmd line commands.
Here's how I set my project up assuming you're also on windows:
download forge src (looks like you're using 1.7.2)
extract the contents into an empty folder
point a cmd prompt to this location
run "gradlew setupDecompWorkspace" (will take a while, should exit with "BUILD SUCCESS")
run "gradlew eclipse" (will take a much shorter, should exit with "BUILD SUCCESS")
open eclipse and switch your workspace to the "eclipse/" directory in the same folder you extracted forge into. (e.g. C:\Users\ME\Desktop\FORGE_FOLDER\eclipse)
If follow these slowly and carefully there should not be any issues. If there is then that means you may not have admin privileges or may be on a restrictive internet connection.
Edit: the package declaration issue on line one is because in your project explorer it says src/main/java/com...etc when it should be src/main/java and then that contains the package starting with "com"
To do this, right-click src/main/java/com... -> Build Path -> "Remove from build path".
After this you must drop down src, drop down main, drop down java. right-click java -> Build Path -> "Use as source folder"
Edit: easy way to access cmd in right folder is to open the folder where you extracted Forge and click in the address bar at the top of file explorer and delete what's there, type "cmd" hit enter.

Related

Can't find workspace outside of eclipse

I checked the src folder (inside the same folder that I have my eclipse folder in) to make sure all the class files were there. There were none, in fact it looked completely different and out of sync from my project.
Is there some other folder or place where eclipse keeps my code ?
By the way, I use Mac. Also, don't think it should be a problem but I keep my eclipse application on a flash drive (the actual install location for eclipse is on my computer, though).
Right click on your code base in eclipse & select properties. In the properties tab you will find the disc location of your project.
When you first setup eclipse you are asked to choose a workspace. The workspace is where your code is saved. If you right click on your project and click properties, in the resource section there is a spot labeled Location: The file path there is where that project is saved. (It will be under your workspace folder)

Eclipse won't compile/run java file

I am just trying to compile and run a simple java program. When I go to run my tester class it says select what to run and it gives me Ant Build which when highlighted says "Launches an Ant build with default settings" or Ant Build... that says "Launches an Ant build and allows it to be configured". When I try to select either of these it prompts Build failed. Reason: Unable to find ant file to run. I honestly don't know what these ant builds and files are. This is definitely a dumb question but have no idea what to do.
Make a project to put the files in.
File -> New -> Java Project
Make note of where that project was created (where your "workspace" is)
Move your java files into the src folder which is immediately inside the project's folder.
Find the project INSIDE Eclipse's Package Explorer (Window -> Show View -> Package Explorer)
Double-click on the project, then double-click on the 'src' folder, and finally double-click on one of the java files inside the 'src' folder (they should look familiar!)
Now you can run the files as expected.
Note the hollow 'J' in the image. That indicates that the file is not part of a project.
I was also in the same problem, check your build path in eclipse by Right Click on Project > build path > configure build path
Now check for Excluded Files, it should not have your file specified there by any means or by regex.
Cheers!
right click somewhere on the file or in project explorer and choose 'run as'->'java application'
This worked for me:
Create a new project
Create a class in it
Add erroneous code, let error come
Now go to your project
Go to Problems window
Double click on a error
It starts showing compilation errors in the code.
Your project has to have a builder set for it. If there is not one Eclipse will default to Ant. Which you can use you have to create an Ant build file, which you can Google how to do. It is rather involved though. This is not required to run locally in Eclipse though. If your class is run-able. It looks like yours is, but we can not see all of it.
If you look at your project build path do you have an output folder selected? If you check that folder have the compiled class files been put there? If not the something is not set in Eclpise for it to know to compile. You might check to see if auto build is set for your project.
What I did was I created a new project and opened the file location from my old project and new one. Then I copied everything from the old project besides the run file, and ran it on the new project and now it works fine.
the file is probably located in your project package but is not yet compiled so you are able to open it as a java file in your eclipse java project, here is what I did in my case: in eclipse, goto terminal window, cd to your project directory, then cd to your project package, then run javac yourFileName.java, finally right click your java project or project package in the project explorer and... you should see the file there, and it should now run for you as a java file... hope this helps!!!

IntelliJ - How to jump to source instead of compiled classes from failed unit tests in the "Run" view

When I run my JUnit tests in IntelliJ and one of them fails, I would like to jump to the source code of the failing test by double-clicking it (or by right-clicking it and selecting "Jump to source" or "Show source") in the results view (in the list of failed tests in the "Run" view). However, this feature doesn't always work correctly. Sometimes the source code is shown and sometimes only the compiled ".class" file of the test is shown to me in the editor window.
I would always like to see the source code (".java" file) instead of the ".class" file in the editor window after double-clicking the failed test.
One solution for it is to click "Attach Sources..." in the editor window, where the ".class" file of the test class is displayed. However, I have to do it for every test file and it takes much time to do it repeatedly for every test. In my opinion IntelliJ should find the source code automatically, because it's present in my Project (it's my own class and its source code is in the project and I run this test from the Project view, where the classes with source code are visible). How can I configure IntelliJ, so that it finds the source code automatically for every unit test which I run?
The ".class" files which are shown instead of the ".java" files are contained in a jar file which is built by Maven.
You should be able to go to the External Libraries in your Project view (File > Project Structure), find the jar that contains the .class file, and right click (or F4). You will see Open Library Settings. From that dialog, you can attach a src folder to the library.
I'm using IntelliJ IDEA 2019.3 ultimate edition and faced this issue, debugger would jump to decompiled .class files
On the top right corner once your debugger jumps to .class file
you will see an option to 'choose sources', choose the directory which has your .java file. Worked for me atleast.
I had a similar issue. In my case it was due to incorrect Module configuration. Basically you must ensure that the source folder containing the java files is added to Sources tab in corresponding module.
To do this Go to Project Structure (Ctrl + Alt + Shift + S) and select Modules. Choose corresponding module and verify that the source folder containing the java files is correctly added to the Sources Folders. If it is not then add it.
I got this issue today. The solution for me was to right click on main pom.xml, then maven, then reimport.
I Had a similar issue. The issue was still there even after pointing to the correct source folder but I got rid of it by setting the classes folder to the source code's root folder.
Add a solution to JAVA Maven project.
Open 'Libraries' from 'Project settings', search and select the Java jar you want to attach source file. Then you can add source directory by click the '+' button.
I Had a similar issue. The solution for me was to close project, delete .idea folder than re open the project.

Editor does not contain a main type - messed up Build path config

Does anyone know of any complete guide that shows how to reconfigure from scratch the "Build Path" in Eclipse?
In the attempt to add a .jar file I messed up the current configuration. Or if you think volunteering pictures of your Eclipse config screen may help, that would be appreciated it too!
I hope I will not have to reinstall Eclipse.
The error I keep getting (for any classes, also those who used to run perfectly) is: "Editor does not contain a main type." (BEFORE any program even LAUNCHES).
I had deleted JRE but then I put JRE back by right clicking the root of "package explorer" - Build path - Add libraries - JRE System Library. Still same error.
The "Build Path" -> "Configure Build Path" tool can be used to fix a lot of problems that other build path modifying techniques can cause.
Open that tool and look through the tabs and see if you can find the entry that is causing the problem. Pay special attention to the Libraries tab. You may just want to remove all the entries in this tab and re-add the ones you need one by one. Build path problems are often broken entries in this tab.
You might also try looking through "Run" -> "Run Configurations" tool and remove any run configurations associated with the project.
I didn't have any source folder added in the Build path configuration. I just went to Build Path configuration and added the folder in the "Source" panel. (I had previously deleted it by mistake.)
This solved my problem, now my applets and console classes run perfectly like they used to.
http://zenverse.net/editor-does-not-contain-a-main-type-error-in-eclipse/

Missing .classpath file in Eclipse project

I have recently returned to a project after not using it for a couple of weeks. The project was not created in Eclipse it was imported, and there is no '.classpath' file in the project workspace.
I am sure that previously I successfully added new .jar files by simply right clicking them and going to 'Add to build path', but thanks to an unrelated error I had to re-add the files to the build path, and now whenever I try to add a new .jar file I get the following error:
Error while adding a library
Reason:
Could not write file C:\Users\Charles\workspace\hive\.classpath
Or, if I try to add a file using Configure build path, I get the following error:
'Setting build path' has encountered a problem.
Could not write file:
C:\Users\Charles\workspace\hive\.classpath
I have earlier versions of this project prior to adding .jar files, and there is no .classpath file for any of them either, so I haven't accidentally deleted it at any point.
If anyone can help me out at all, I'd be ever so grateful (I desperately need to add these .jar files so I can do some actual work).
The thing that annoys me the most is I'm sure it worked before, but I have tried to do the same in earlier versions of the project and I am always getting the same error now.
I had the same problem. I had just setup a new PC, I transferred my projects to the new PC, clicked on the workspace directory, and changed the permission so that I (the 'me' on my new PC) owned all the files in all all sub-directories. However, even after doing this, eclipse couldn't write to the .classpath files. I verified that I could write to them using notepad, and that worked fine. I also verified that the O/S knew I was really the owner, but it didn't help. I also tried running as admin, but that didn't help either.
Then I found this link: http://blog.ryanrampersad.com/2010/03/03/setting-build-path-has-encountered-a-problem-in-eclipse/, which indicates that when you copy files to a windows7 machine, windows may set the 'hidden' attribute on the file, and when this happens, eclipse can't work with it. I did a find files from the workspace directory, looking for '.project' (and subsequently '.classpath'), and selected all the files, right-clicked, and un-checked the 'hidden' attribute. This fixed my problem.
The .classpath file in eclipse is a configuration file (in XML) which stores the project classpath properties. If it can't be written, perhaps it's an access problem. Right-click the file in windows explorer and check under the security tab to see if you have write permissions. You may have to run Eclipse as administrator.
Go to your Project in WorkSpace.
And then change your files' attribute from hidden.
Also, then close-open your project and then clean it.
This should work.
Right click Project >> Source >> Format - worked for me!
Go to the project folder and remove hidden property for the ".classpath" file. Hope this helps. Thanks.
The below solution worked for me.
Go to your project folder --> Right click folder --> Properties --> In general tab, Uncheck the attribute(last field), Read-only (Only applies to this folder) option.
Then try adding jars in eclipse.
Hope this helps
As doc_180 mentioned, the .Classpath would be hidden. Right click > Properties and Unhide the file, you should be ok.
Just had the same issue after trying to create my view on a new PC. The cause of the issue for me was that .classpath file was marked as read-only, for whatever reason. To resolve this I did the following:
Go to workspace directory --> Java Source folder --> Project Directory --> right click on .classpath and select Properties from the list --> uncheck 'Read-only' and/or 'Hidden' attribute checkbox(es) --> Click 'Apply' button.
I had a similar problem after changing my project to Gradle. When I right-clicked on javaw.exe->Properties in the 'debug' view, I saw the classpath was (mostly) missing, for instance the 'bin' directory containing the classes wasn't there.
Solution for me was just to delete the 'run debug configuration' and create a new one. After that the classpath was included and I could run it from Eclipse again.
Hope this helps someone out there.
An intern here just had this problem. He put the project on the user Document folder. I moved his project to the Eclipse workspace folder, removed the project from Eclipse and imported it again. Then the .classpath file was generated.

Categories