Running a pre-existing .java - intellij-idea

I'm switching from Sublime Text 3 to IntelliJ, I had a test.java file on my desktop that I used for small testing but now I am not able run the same in IntelliJ, the problem is it's not showing the file when I select run.
I tried experimenting with different projects created through IntelliJ and understand that I need to set Project to run the code, but again I don't see the file I want.
Here is the project selection screen
Here is what happens when I hit run

See this answer and this document.
You need to configure the content and source roots inside the Java module.

If you right click on test.java and click "Run 'test'", that will attempt to run your main class. Although you may have a NullPointer exception in your code. When you attempt to access a.get(0), the value will return null as there are no Integers in your ArrayList. Also generally class files are named with uppercase first characters. Hope this helps!

Related

Intellij and vscode doesn't run a Hello World java program

like this the program seementer image description here
after i setup intellij i tried to run my first java program but it doesn't work and always shows the message of "Abnormal build process termination"
and i tried to work on vscode but it also doesn't work
Looks like from your output that you named a folder with a ? at the beginning (C:\Users\?...) and apparently Java doesn't like that. Try moving the project in another folder or try renaming it.
(Post the whole output if you can, it's filled with useful info)

How can I run only single kotlin file in Intellij

I have a problem when i run Kotlin file in Intelij.
I want to run only one kotlin file that is AbstractVehicle.kt
under the image is code of AbstractVhicle.kt
However, I got an error. because always run with other Kotlin files when I run!!
I tried to run using variety way to run only AbstractVehicle.kt file (ex:for example control + shift + R or control + R... My laptop is Macbook )
please help me.. how can run only one kotlin file
First, Click file AbstractVhicle.kt. Second, right click. Third, click run AbstractVhicle main method.

No coverage in 'all classes in scope' in Intellij

In Intellij IDEA 14.1.5 Community edition, I imported maven to get coverage from jacoco.exec file. Steps followed
right click on imported module.
select Analyze-->Show Converage Data.
provided valid jacoc.exec file and click 'show selected'
Instead of coverage i'm getting error as no coverage in 'all classes in scope'
can anybody suggest what is wrong?
I had the same thing happen to me.
I was able to fix this by going to "Edit Configurations", to the "Code Coverage" tab.
I'm not sure what caused it, but the wrong package namespace was listed there. I updated the entry there and my subsequent test run with code coverage succeeded.
It happens if your test class and class to test are in different package structures.
My test class was in:
com.tools.api
Class to be tested was in:
com.tools.ws
Once I've corrected the pattern as com.tools.* in the code coverage tab, I was able to see coverage results.
I had the same problem and found solution here.
In the Code Coverage tab, define the following options:
Specify the scope to measure code coverage for. Do one of the following:
To specify a class, click the Add Class button.
To specify a package, click the Add Package button.
I was able to fix this issue by:
Open Edit Configurations menu
Click on Modify Options > Coverage settings > Specify classes and packages
In the new box that appears, click on the plus to add a package
Select a high level package from the project

IntelliJ 12, module-depenencies all red, no path.

I have a real problem with making Play2.0 work with IntelliJ EAP version (120.152).
I create an empty project without module in IntelliJ
I create a new application using the play command, and using play idea at the end
I then add this module from IntelliJ, using "Import from existing module"
Now, I have two folders too chose from when importing the module.
1. .idea
2. .idea_modules
After seeing some different ways on the internet,
I chose .idea_modules -> moduleName.iml
(I have tried all the others just to check)
Here is what bothers me the most
Anyone had anything similar? I am not sure why this is, every other screenshot I have seen from this, have a path behind the red text (making it work!), which I do not.
Any suggestions what I can do from here to hopefully make this work?
My Scala facet looks like this in the IDE, but I have not seen any Play documentation that goes into modifying the facet, so I just leaved it as is
In IntelliJ 12 - the same as in IntelliJ 11 you can open the Play's project since version 2.0.2, just by using option 'Open project' in the start window view.
You don't need to create blank project first in IDE.
play new test-leda + all required steps by play console
cd test-leda
play idea + wait for bash prompt which indicates finalization
Open Leda and choose Open project
Find the folder test-leda and just click Choose
That's all

Netbeans - Executing files in different projects with [SHIFT]+[F6]

In Netbeans you can run a file by pressing Shift + F6 (on Windows)
So I have three projects open at the moment.
What I want to do is jump between the three projects and compare the results of executing a program in each of these three panes.
Netbeans seems to have a problem with this. It doesn't seem to be able to recognize that I want to execute a file in the project I have just jumped to - instead it simply re-executes the file from the project I was previously in - OR - it does nothing at all.
Am I doing something wrong?
In netbeans 6.5, you can choose to not set a main project.
Run >> Set Main Project >> None
This means that, what ever file you currently have open, when you tell it to run, it will run what ever file you have currently got open, and treat that project as the main project.
http://wiki.netbeans.org/mainProjectConceptualChange
Hope this helps!
By default, When you try to run some code, it will run what ever project you have currently set as the working project, not what project you are viewing.