Can't create a class within intellij - java

Edit: The solution to the problem was to uninstall and re-download and install intelliJ.
I am unable to create a class following online tutorials. One method is to expand the project folder and right click src and from there you can create a class, but I am unable to expand the project folder in intellij and therefore am unable to access the src file to create a class. The tutorial video shows an arrow next to the project that you can click to expand the project, but I don't have this arrow. Please help I am new.intellijScreenshot
This is the tutorial I used: https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-application.html
I created the SRC folder like someone suggested and now the project expands, but there still is no option to create a class.

This has to be an issue in the way the project was setup. When you create a new project, IJ creates three things in your project, a src folder, a .idea folder, and a .iml file. Without the .idea folder and .iml file it wouldn't let me create a new class either. Delete your HelloWorld project, and try again. If still no luck, maybe try uninstalling/ reinstalling. Could possibly be an issue with the JDK, I don't mess with that, I just use 11 version 11.0.6.... Hope this helps!

Related

Empty SRC folder after import from github

I'm currently working on a groupproject. We're using github to save our code. I have just installed eclipse to work on. I foound to open the project to use import. This has opened the project, except the SRC folder is empty whereas the first SRC folder (the main which was made through github) has several .java files within.
Why is this and how do I go about putting them in. I am unable to work on the code through eclipse at the moment due to this. Thank you, much appreciated.
The easiest way would be to:
clone manually the GitHub repo (in command line)
import the Eclipse project in your Eclipse workpace
Then push to the GitHub repo
Or you can clone the GitHub project through Egit directly,, following this tutorial.
The OP pokeairguy reports in the comments an alternative solution:
create a new project in eclipse like normal.
Then drag the contents of the src folder from GitHub into the folder directory within eclipse.
Then selecting link in the pop up window.
I think it works by thinking its a new project but saves everyone done under the GitHub folder, for GitHub to work.

Android dependancies configuration

I am going through the Android app tutorial here:
http://developer.android.com/training/basics/actionbar/styling.html
As part of what I am doing I added in the appcompat library as part of adding in the themes. Not sure how I got to this point but when I try to run the app I get the error :
"The container 'Android Dependencies' references non existing library 'D:\eclipse-bundle\sdk\extras\android\support\v7\appcompat\bin\android-support-v7-appcompat.jar'"
The library DOES exist, just not at this location. It is located at:
D:\eclipse-bundle\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar
There does not appear to be any way to edit this property. How do you fix this problem? what is causing it?
Thanks in advance for any help.
Make sure you follow this step to add .jar files.
In the new library project, expand the libs/ folder, right-click
each .jar file and select Build Path > Add to Build Path. For
example, when creating the the v7 appcompat project, add both the
android-support-v4.jar and android-support-v7-appcompat.jar files to
the build path.
I had the same issue so I CMD+Q'd Eclipse and re-opened it.... magically worked. I guess "turning it off an on again" works sometimes :D
You can select your project on eclipse, then right-click...
A menu should appear, you can click on "properties".
A flying screen should appear, you can click on "Java Build Path"
Another flying screen should appear, you can click on the tab "Libraries"
This tab actually hold references to what is in the "libs" folder, and you can delete your old lib and insert your new lib (with the correct path) there.
Would not recommend any of it, actually... Please just import the "support lib project" into your eclipse workspace and make your project reference the imported project as a "lib project".
That is way more handy, and will actually give you a better flexibility for doing more stuff with compatibility lib.
And also, since it is on your workspace, you are the one that compiles it. No future lib reference problems \o/

Intellij IDEA Project view doesn't show structure as it did before.

My directory structure in the Project seems to have disappeared. The first picture is the "bad". I recently upgraded to 12.1 and the vim emulator at about the same time. I don't know if I missed a dialog that reset something? I can't figure out how to get it back like the second picture.
I've tried to re-import the project but it has not helped. I keep the project on Dropbox and have another PC where I have not reloaded project. Is there a way to get my view from that machine?
The picture is the "good" and how I want it to look.
I've come across this problem a few times myself. What happened is that intellij lost the module in my project settings. Here's my steps to fix it:
File -> Project Structure -> Click on modules (notice empty list) ->
Click on '+' -> Click on import module -> Find existing myProj.iml
I also have quite a few IntelliJ projects and also git folders of text files. I found IntelliJ does not always reconstruct the .idea files correctly. However the following methods work for me.
Open IntelliJ in the top folder where there is no .idea folder. Often IntelliJ will just construct a new .idea folder and works.
Copy an .idea folder from a similar project and modify to fit. The xml files in the .idea are reasonable to modify.
Open IntelliJ in the root project level works for me.
I have a mixed project folder tree like the following:
git_root
- proj_android
- proj_ios
- proj_react
- lib
- src
My problem is that when I open IntelliJ on my proj_react folder, I could not see my src folder or lib folder. (My proj_react is one level down from my git_root.)
Then I open IntelliJ on git_root, I could see everything. The problem is solved.
If you are working on a software development project where you are using Maven, Gradle, Flash Builder etc., the below mentioned steps should restore the project structure:
Ctrl+Alt+Shift+S (or) File>>Project Structure
Select 'Modules' in 'Project Settings'
Alt+Insert (or) Select '+' to add a new module
Select 'Import Module'
Select the folder you want to import the module from(Generally the parent folder)
Select 'Import module from external model' and the corresponding external model
This resets your project structure.
You can sometimes rescue projects like these by going and resetting their content root in the module settings. Or even recreate the module as another answer suggests.
This is something that would happen to me if I opened an IntelliJ project in PhPStorm, then tried to open it in IntelliJ again.
However as was mentioned the project format changed recently, so you should use the same version of intelliJ to work on your project.
If you have a content root for a project module that intersects with another content root, then this problem will occur. For example:
Project A (content root)
- source for A
- module B (content root)
- source for B
If you have a project that has a source root for "Project A" and you add a source root for "module B" you will end up with missing structure, such as your first picture. This happens because the content root for module B is within project A structure.
This worked at one time, as I have the setup above with multiple modules. When I upgraded to 12.1.6 this stopped working. If you have overlapping source roots you will see this problem.
I'm using 12.1.6 on windows 7.
On Mac:
Preferences
search for Project Structure or go directly to:
Project: Your_Project_Name / Project Structure
Mark all as Sources (mine was marked as "Excluded")
What did you update from? If you did a few major versions update, intellij really changed how their projects are laid out. You probably need to edit the projuct structure and add a new java module.
This issue is 8 years old and the problem still exists in IntelliJ. For projects with many modules, it can be a real pain reconstructing them after each time this occurs. I suggest that once you reconstruct the modules, back up the .idea folder so you can easily restore it next time
In the bottom left corner of IntellIJ you'll find an icon, using which you can fetch project structure, etc..,
This is the quick fix that i have done:
Close the IDE and open the project folder in file manager
Delete the .idea folder and reopen the project in IDE.
To view the hidden folder and files:
Open the folder and press cntrl+H (in linux), And in windows Go to folder options and check view hidden files option.

NetBeans open project problem

I created a NetBeans project. I took the project folders zipped to another machine and tried opening it in NetBeans. NetBeans didn't identify it as a NetBeans project. I have transfered projects in this way before but why is it not working now? Are any of my project files corrupted. Is there any way to retrieve my files from this?
Try using create new project from existing resources. This may solve the issue.
I just copied whole project into place in system where NetBeans stores projects (in windows it's user\username\Documents\NetBeansProjects\ by default), then started NetBeans and voila - worked great :)
You can try this:
Create a new project on the target machine
Find where the project you want to open is stored and open the src folder.
Copy all the files and stuff in the /src folder
Go on Netbeans, expand the tree view of the project you have just created, right click on source packages and click paste. It should paste the files in the /src folder as packages. You should also see the code these packages contain.
I discovered this solution and it worked for me: http://netbeans-org.1045718.n5.nabble.com/Netbeans-Crashes-Since-Windows-Update-td5752603.html
The fix is to remove the GodMode shortcut that may have been created on your Desktop or on the root of the %systemdrive%.

How to import java classes from other projects in NetBeans 6.8?

I have just started playing with Java, and I really like the language. I am using the NetBeans IDE, and I find one odd oversight. I can create a new class in a project, but NetBeans doesn't appear to support any way to import an existing class into a project.
I manage to get it done by going to some other project where the desired class already occurs, and then I copy/paste it into the source code folder of the new project, then change the package name at the top of the pasted file to match the package name of the new project.
Is there a nice direct way to do this from the NetBeans interface?
Thanks for any help on this.
In the Projects window you can expand the project that you are working on. Right Click on Libraries and select Add Project.... You will get a dialog allowing you to select another Netbeans Project with the Java classes that you wish to use.
You have to just make the .jar file of that/those java files which you want to use in another project.
right click on file->export->java->.jar then finish.
Now you can use these jar into your another project.
When you build the java project in netbeans it creates a jar file on the dist folder in the current project directory.
You can use this jar file for the other project as a package by adding this as ADD jar in the next project.I have tried this ,i am using my old project jar file for new project development.
Use the 'Clean and build' your project option from the netbeans application, that creates the 'dist' folder which you are looking for (and obviously can't find because you havn't cleaned&buld)
The netbeans itself creates .jar files and you can add the jar file to the current project you are working on.

Categories