How can I run only single kotlin file in Intellij - intellij-idea

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.

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)

Can you save variables in Visual Studio Code?

I am trying to teach myself code/automate some tasks in my downtime at work, and the IDE that IT installed for me use python with is VSCode, which I don't seem to understand fully.
My only formal education in coding was using matlab. I remember being able to define a variable or function in my code, run it, and then call the very same variable/function in the terminal, which would return what I had defined. There was also a workspace directory that showed all the variables I had stored. However, is VSCode, i cannot find anything like that - I even had to install a separate package to RUN my code. Is it possible to have VSCode do what I described above in matlab? It was a long process getting IT to install VSC so I really do not want to try to get a new interpreter unless I absolutely have to. If there is some significant difference in matlab and VSC that I am not grasping, I would appreciate if that could be explained because I feel very much in over my head right now.
testVar = 8
I would expect to be able to type testVar into the terminal, and have it return 8, but instead:
testVar : The term 'testVar' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ testVar
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (testVar:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
As rioV8 mentioned in the comments to the OP's post, if you enter python in the terminal, you get the python REPL which is like the command window in Matlab. You could then try commands to display the list of variables (which I don't recall at the top of my head), but I don't think you can get the visual display like Matlab's workspace.
For that, one option is to set a breakpoint at the end of your code, and run the code in debug mode (F5 on Windows). Then you can see the variable workspace as well as play around with the values using the debug console (which acts like a command window during debugging).
However, for more frequent interactions between the code, workspace, and command window, I recommend using jupyter notebook instead. There you can run code and view the variable workspace (search variable in the command palette (ctrl + alt + P)) in the variable explorer. Hopefully your python setup includes that option; you can try creating a new file in VSCode with .ipynb extension.

Running a pre-existing .java

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!

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.