Yesterday I downloaded JDK and Netbeans as my IDE. When I attempt to create my first ever Java project, I get
"no main class found"
as shown by the screenshot below
What do I do for the correct setup please?
I have since clicked on Properties>Run
and still have the same problem.
The syntax errors are shown in the screenshots below.
Would it have anything to do with my setup of src folder?
Right click on your Project in the project explorer
Click on properties
Click on Run
Make sure your Main Class is the one you want to be the entry point.
Click OK.
Run Project
Related
I was programming a fabric minecraft mod in intellij and when I ran the code it said :
Could not find or load main class net.fabricmc.devlaunchinjector.Main
When I compiled the code and tried it in minecraft it worked, but in intellij i couldn't run it.
I was messing around with the files, to see if I can fix it and I found a solution :
Go to "Run Configuration", press the arrow to see the options and tap "Edit
Configurations"
Go to "Minecraft Client" and press the button next to
"net.fabricmc.devlaunchinjector.Main"
search trough your external libraries and find "net.fabricmc.devlauncherinjector.Main"
(it must be right under net.fabricmc-api...) select it, and after that you should see
the "Edit Configurations" window. Press "OK"
If this doesn't work, right click the file and select "Copy Full Path". Then go to
"Edit Configurations" window and paste it where it says
"net.fabricmc.devlauncherinjector.Main"
If the 2 option doesn't work either, close the project, copy the mod folder, and paste
it somewhere else(eg. Desktop, New Folder). And then open your IDE, go to open project
and select the copied folder. Press the "Build.gradle" file and select open as project
and "Trust" .It should now work. If it doesn't , unfortunately I don't know how to fix
it.
thecoopsyt's answer worked for me.
Go to Gradle tab > Reload All Gradle Projects
Wait a few mins for it to check and update your dependencies.
After this I was able to return to testing my project in Intellij... had to fully compile and test before this fix.
In Intellij gradle if
this doesn't work you can put
downloadAssets runClient into a gradle config and it will start a client and download the net.fabricmc.devlauncherinjector.Main
this allows you to use gradles built in Minecraft Client
I was importing the source code of a Java game to my local IntelliJ (community edition 2.3.2019) and try to make it run. I'm new to Java btw.
I got the code from here: https://github.com/janbodnar/Java-Space-Invaders
What I did is download the code from the repo, export the zip file in a folder and import it as a project in IntelliJ. After importing a lot of my project files appear red as you can see here:
IntelliJ red icons
My first question is: Why are these icons red? And how can I find out why IntelliJ is marking them red? I tried by hovering over these icons, but nothing happens / indicates what's wrong.
Also: Afaik in order to make this project run I need to take care of the run configuration. I tried this, but the main class is not choosable if I choose the path com.zetcode.SpaceInvaders.java (where the main class is part of the code).
What am I doing wrong? How can I run this project/code in IntelliJ?
Many thanks in advance.
You need to follow these steps:
1. IntelliJ -> New Project-> Project from existing resources(the unzipped code directory).
2. Follow the next steps as given by project explorer.
3. Remember this project uses jdk above 10 as it uses "var" keyword.
4. So, go to the project settings if the jdk in step 2 was selected below 10.
I couldn't see any red marked files. I just ran the SpaceInvaders.java file to run the project & the game started.
I have just imported my android project into intellij from eclipse. I am new to intellij.
I have gotten everything working and set up the run configuration for Android. When I run it, it gives me the edit configuration screen.
When I say launch the default activity, it tells me that it can't find the default activity, which is odd. When I code the activity to launch straight away, it tells me that that's not an activity subclass or alias. I double-checked and the class is certainly an activity.
When I ignore it and run anyway, it blows up as soon as it hits the phone.
Can you help me understand/fix these errors, please?
In the Intellij project structure dialog, select the module that your Activity is residing in.
Then under the sources tab, add the root folder of your sources as sources for this module by clicking the 'Mark as Sources' link or button. The sources root folder should be mark blue.
The module can now find your sources and launch the activity.
My solution was to delete and recreate the run configuration.
In my case, none of these solutions worked. Then I started digging.
As I remember, my java files had to be placed in src/main/java/com.something.blabla. Then I realized that the directory has changed to src/main/java/com/something/blabla.
So I created a new com.something.blabla folder under ../java/ and moved my java files to that folder. I removed the com folder, and it worked perfectly.
I have to build a Decision Support System, but dont have much experience in Java. So after I connected to MySql with Eclipse (with Connector/J) eclipse started to mess up my other projects. Now, when i try to run other projects in eclipse (that are not related to MySql, ex. Guessing Game) the following error message apperars:
Launch configuration DocsConnectionPropsHelper references non-existing project MySql connection test.
Can anyone help me to resolve this problem please?
UPDATE. it seems that when i press "RUN" elcipse is not running the project that im working with, but other
Your update indicates the issue is actually running the wrong project. To avoid that you may want to close projects you're not working on (right click them in package explorer and select close).
If you do need multiple projects open then when clicking the run icon (which defaults to re-run whatever was ran last among your open projects) make sure you have open in the editor window something that can be ran (and is from the project you want to run).
Then click the drop down arrow to the right of the icon. This will open up a small menu with options to change your build configurations or how it should run your program (i.e. as an application or on a server).
To solve the problem:
-click right botton on the project package you want to work on (run)
-choose Run As
-choose Run Configurations...
-choose DocsConnectionPropsHelper - if in the Project box you see not correct title just remove it. Also remove anything what is in the Main Class box.
-click Apply
-the best option is to close Eclipse and reopen it to make sure that all the settings were configured
It worked for me. Hopefully it will work for you too.
I'm working on an Android project. Something happened with my Eclipse project and I can no longer "see" any of my source files in the project explorer. The project explorer only shows :
src (clicking and trying to open yields nothing -- I can right click and open in a new window and see a bit more, but still can't decend the directory and see files)
gen
android.jar
usb.jar
maps.jar
My java files are still in the directory.
It looks like the project is corrupted somehow? I have tried deleting everything in .metadata/.plugins/org.eclipse.core.resources per some suggestions I've found but that doesn't seem to fix it. I created a new test project and it looked ok last night when I created it, although now, it to shows the same behavior as above. I'm using eclipse indigo service release 1. See the image bellow:
It's because you have the wrong view open. Try to open the Package Explorer
Window > Show View > Package Explorer