Cannot be resolving in JAVA - java

I'm new in java and found this after importing project
How can i solve it?

Go to Window > Show View > Other.... Choose General > Problems or search for Problems and add it. Look for the exact reason for red marks on your packages.
Update
Looks like your source folder is misplaced. Follow the steps below:
Right click on the project, go to Properties
Choose Java Build Path on the left pane.
Click on <Project_name>/src and click Remove
Click on Add Folder, choose check boxes (if found) java & resources under the trees src>main and src>test
Click OK and then OK on Properties dialog.
Image reference:

Related

Unable to find or load Main Class in Intellij 2019.4

I have been at this problem for a few days now, don't know why it is still happening. I have tried other solutions that have been posted on stackoverflow but no luck.
Below the following code is from the book crafting interpreters in java.
In IntelliJ 2019.4 this error always pop up when I am trying to run the .jar file.
Error: Could not find or load main class com.jam.Jam
Caused by: java.lang.ClassNotFoundException: com.jam.Jam
I have built the .jar file and setting the main class as com.jam.Jam and the class path for the .jar file as /home/username/Jam-Programming_Language/src/com/jam/Scanner.Scanner.
This is the layout of my project directory.
The following solutions I have tried:
Solution 1
Open Project Structure
Select Modules, then click on the module for which you want the
dependency
Choose the Dependencies tab
Click the '+' at the bottom of the page and choose the appropriate
way to connect to the library file. If the jar file is already
listed in Libraries, then select 'Library'.
and
Solution 2
Go to the Project Structure, click on Modules, and click on your
Module
Choose the "Dependencies" tab
Click the "+" button on the right-hand side and select "Jars or
directories..."
Add the directory(ies) you want (note you can multi-select) and
click OK
In the dialog that comes up, select "classes" and NOT "jar directory"
Make sure you're using that Module in your run target
It had no effect apparently. Any clue on what I should do?
Edit: Uploaded wrong screenshot, replaced screenshot.
Thanks to CrazyCoder for pointing out the errors in my project (silly mistakes). It seems that after I have resolved those mistakes.
I had to follow the solutions I have posted then rebuild the .jar file.
Afterwards I need to mark the src folder as a source root folder (right click folder -> Mark Directory as -> sources root)
Edit Configurations if pointing to wrong main class.
Set Project compiler output (File -> Project Structure -> Project) to a folder designated to hold the output (any folder basically in or outside the project).
The error says, it is trying to run: com.jam.testfile. Your class is called: com.jam.Jam.
Click the dropdown where it shows "testfile" with a little red X on it. Select "Edit Configuration." For the "Main class", select "com.jam.Jam". That's it!
BTW, the little red X means there is some problem with your configuration.

Intellij right-click 'New' is not showing 'Class'

Related: IntelliJ does not show 'Class' when we right click and select 'New'
In the above accepted answer, it says the "New" does not give the option for Java Class because it was not the source root (blue directory).
However, as you can see, even though where I am right-clicking is source root, indicated by blue box, it is not giving me the option for Java Class
Any idea why?
This directory is imported from git so it did not follow the usual "Create Project" for java directly from Intellij
You are right clicking in the wrong spot -- youre "too high" up the tree. Go to where you code is (as in the package under "src") and try it there and you will see the option for a New Class.
EDIT: You don't need to be in the source root. You need to be in the source directories themselves. The blue dot I believe is a git status indicator. What you want is an entirely blue folder.
Go down under "src". Likely under "src" then "main" then "java", and you're there (that's blue for me) and then you will see your package folders. Below those are where you likely want to be adding classes.
As many mentioned above you can right click on the folder you would like it in. In your case:
If you push Alt+1, it might be easier for you to right click
src > New Java Class
Alternatively you can push:
Alt+1 (Project View)
Alt+Ins
or
Ctrl+Alt+Ins
1) Right click on src
2) Click New > package
3) Name your package and press OK
4) Right click the newly made package
5) New > Java Class
If the folder where we are trying to create the class is not marked as source or test then the option is not available.
Right click the project and go to project structure then under project settings -> Modules, Select the folder where you wanted to create class and mark as Source or Test appropriately and then click apply and ok.
Now you will see the change of color of the folder/package(Sources->Blue, Test->Green) and you will get the option to create the class.
This worked for me.
I know this is an old thread, but it happened to me because my gradle files were not synchronized. So if you are within a team working on same project and face this issue, make sure to run gradle sync.
You should go inside java project then you can create java class.

Eclipse showing java project src folder view as all packages and subpackages

Not sure how to really ask this question since I don't know what everything is called but I'll try to do the best I can.
So as I was cleaning up my classes. I right clicked my project and selected refresh. Then all of a sudden my project view changed, the src folder shows everything as packages and '.' separated subpackages. And all my code package declarations seems now to be undiscoverable.
I've attached a photo, hopefully you can petter understand this...How can I fix this to have the correct directory view/structure.
Edit:
Here is what I have linked to my JAVA build path
I don't understand what is happening? How can all of a sudden my project screw up like it has? Any help will be much appreciated
Look at the 'Java Build Path' in the project 'Properties' and check that you have the correct 'Source' folders. It looks like you may have just 'src' as a source folder when you should have 'src/main/java', 'src/test/java'...
I was able to fix this by maven>update project, then just refresh...
In addition to the previous answer you also may use empty package filter:
At the top-right of the Package Explorer view, there's a downward-pointing triangle. If you hover your mouse pointer over it you'll see View Menu.
Click the View Menu, select Filters, put a check next to Empty Packages, then click OK.
Same way you could tune other options for Package explorer such as file types to show etc.
Well, it seems pretty clear that your hierarchy does not match the name of your package, so just fix your hierarchy. It will be easier if you switch to the hierarchical view of the packages. To do so, go to Package explorer, View menu (arrow icon pointing to the bottom), Package presentation, Hierarchical.
The following worked for me:
Right Click on src (which is shown like empty package in my project) -> Build Path -> Use As Source Folder

splashscreeen not working in netbeans IDE for java?

slash screen tutorial
By following the above tutorial i did the following things
step1: created a new project named SplashScreenTest
step2: include the gif file named laoding.gif in the project
step3: added a new JFrameForm to project with the name StartGUI.java
step4: rightclick the form->properties->code->form size
policy->generate resize code
generate position ->untick
generate size ->untick
generate center ->tick
step5: replaces "Nimbus" with "Windows" inside
step6: right click SplashScreenTest->properties->VMoptions
-splash:src/AppPackage/loading.gif
step7 : open Manifest.mf write "SplashScreen-Image:
AppPackage/loading.gif"
step8: set main class to AppPackage.StartGUI
Now as soon as i hit the clean and build button it returns an error
"existing manifest file is invalid"
May I know what is the correct way to achieve my objective?Maybe this question too basic, but i did't find any suitable solution.Please Help me out.
I'm kind of weirded out by the hoops you are jumping through, Netbeans actually provides support for the splash-screen via the Project's Properties
Right click the project node...
Select the "Application" properties...
Browse for the splash screen image to be used...Netbeans will automatically included within the compiled jar file...
Clean and build your project...

Java - setting classpath

My sample application tells me:
No 'qtjambi-deployment.xml' found in classpath, loading
libraries via 'java.library.path'
I wish for my application to use the qtjambi-deployment.xml, but unfortunately can't find the appropriate setting in IntelliJ IDEA 10.5.
Could someone help me?
You can right click on any directory in your IntelliJ project, select "Mark Directory As...", and choose "Source Root". That director folder will change color from yellow to blue; IntelliJ considers all those directories to be in your CLASSPATH.
From the top menu click 'Run' => 'Edit Configurations'
Choose the right 'Application' in the left column (if it's not yet selected)
Click on 'Configuration' tab in the right hand side column (if it's not yet selected)
Click the '...' button to the right of 'Environment variables:'
Click the '+' button.
qtjambi-deployment.xml file is situated in qtjambi-win<architecture>-msvc<year>-<vertion>.jar. Add this package to your classpath and your building problem will be solved. I hope)

Categories