Intellij IDEA how to run a class not the entire project? - class

is there a way to run (not only compile) a single class (with a main method) instead to run the entire project as does Intellij IDEA?
And, is it possible to open different projects in the same window instead to opening them in a new window or in place of the current project?

You can only have 1 project per window. However, you can load multiple modules into 1 project. Each module can have it's own compiler, language, or any other set up.
If you right click inside the main method of your class, you should have an option to "create MyClass run/debug" or an option to just run it without creating a launch config.

Related

Eclipse to IntelliJ transfer

I have copied my src package structure from eclipse to intellij and it makes this structure within src folder:
How do I make it dz1.drugi so I can one click expand all to my classes?
Another question is how to select default project folder as it is "workspace" at \Users\{Name} for eclipse. Right now, when I create new project like this:
it saves it without workspace (or projects folder) at \Users\{Name}.
Click on the cog icon at the top-right of the explorer view, and check the "Flatten packages" option.
That said, If you get used to keyboard shortcuts top open classes and files, and navigate through recently opened files, you'll quickly see that you'll amost never use the explorer view anymore.
Project view has an option to compact empty middle packages, enable it. You can also use Flatten packages option. Actually, your question is a duplicate of this one.
IntelliJ IDEA remembers the last location you've used when creating a new project. Once you want to create another project, the location one level upper of the previous project directory would be suggested. So, create a project in C:\Users\someuser\workspace\myproject1 and IDE will suggest C:\Users\someuser\workspace\myproject2 for your new myproject2.

How to write an Eclipse component (editor, launcher, ...) that can execute my custom DSL files?

Let's say I have defined a small little textual DSL and I have an 'interpreter' that will parse and execute commands of a file in that DSL.
What is the best way to start such an interpreter in Eclipse?
For instance, I want to double click on a file and, based on the fact that it has the extension .mydsl, start the interpreter. Another option could be using a launcher with "Run As ...".
So should I look at implementing a ...
custom launcher (extending org.eclipse.debug.core.launchConfigurationTypes, http://www.vogella.com/tutorials/EclipseLauncherFramework/article.html), or
editor, that is not actually editing the file, but will be called when the file is double clicked (extending EditorPart, https://wiki.eclipse.org/FAQ_How_do_I_create_my_own_editor%3F)
something else?
Thanks for any hints!
For that I would recommend to implement a custom launcher to get for free:
in main toolbar Run button with history support
ability to share launch configuration via version control (in Common tab choose Shared file)
Launch Group support
etc.
In Project Explorer, Package Explorer, Navigator and similar views a double-click opens a file. In order not to confuse the user you should not change this behavior. But in addition to the custom launcher you could consider to implement an editor with a run button similar to PDE's Product Configuration Editor or a view similar to the Ant view that shows your DSL scripts that can be run on double-click.

Parenthesis in Eclipse Run Configuration

Hi.
As you know, if there is already a Run configuration for a given
class with main type, Eclipse gives parenthesis and number at the
tail of the class name as in the attached image.
But even when there is no preexisting class with conflicting name,
why do I see it with paranthesized number at the end of (main type)
program name, like program(1), program(2)?
Do you have any explanation for this?
In the Launch Configurations window, there's a filter button in the toolbar (the "triple arrows" icon at the top of your screen shot). Clicking that drop-down allows to filter out (or not) various types of launches, including those that belong to closed or missing projects. If you un-check all of the filters you should be able to see the conflicting launch that's causing the name conflict.
I have had this before in Eclipse where I had a project with a runnable class (lets say the class was called MainRun) and then I close or delete the project from the Eclipse workspace. The MainRun run configuration disappears from the "Run Configurations" list. But if you later create a new project with a class called MainRun that you want to run, it somehow remembers that you used to have a configuration called MainRun, even though it is no longer in the list, and so your new one has to be MainRun (1). Could this be what is happening to you?

Netbeans doesn't output application tests

Is it possible to output automaticaly the result of testing each application of a project in Netbeans? I mean output the result with Alt+F6, so that I do not need to change everytime the main class of my project in the properties.
Explanation:
My project has many classes with main methods
so to see the output of one specific application I need to go to:
Right click on the project and scroll down to the Properties
Select run on the left
And then change to the main class I want.
So my question is: is it possible to do it automatically?
Thanks
The answer is Shift+F6 :)
Having one main methode in the package is recommended!
Thanks

Eclipse 3.4.1 - how to view compiler output in Console while building a project

I have what appears to be a very annoying problem. When compiling a project in Eclipse, I see no Console that shows the invocation of the Java compiler and the build results (as in NetBeans).
If I, for instance, import an existing project into Eclipse and invoke Project->Build Project, is there a view that will show me results of the compilation? While I know that my project contains a number of files that have errors, invoking Build Project shows no visual result/progress of the compilation. It does not show the list of errors so that I can quickly jump to them.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with, which makes it very inconvenient to locate and jump to source of the problem.
You can configure the problem view to show only problems in the current project:
Click on the small triangle at the far right of the view.
In the popup menu, select "Configure Contents..."
Select each item in the "Configurations" list and click on "Scope: On any element in the same project"
If you want to see the compiler working, you need open the "Progress" view.
Since Eclipse JDT provides its own built-in Java compiler, you generally do not see the invocation of Java Compiler.
The built-in Java compiler is tightly integrated with Eclipse and JDT, and provides the source indexing that enables powerful IDE features such as refactoring and quick fix.
Plus, it enables incremental build in background after each file modification, hence no visible "java" invocation.
You can replace/complete the java compiler with a javac` call of your own:
For instance, Using Alcatel-Lucent nmake with Eclipse JDT does precisely that, and uses a configuration launcher (which you can instruct to show a console):
You will need to add that special builder in the "builder" section of your project.
Do not forget you can create many "Problem view", and set one of them to show only problems for your current project.
Select: "on any element in same project"
Goto Windows->Show View->Console
or
Alt+Shift+Q,C
Console appears in tab with Problem view
Your question contains a couple of assumptions that you might want to re-think.
It does not show the list of errors so that I can quickly jump to them.
Errors are flagged in the edit window while you are editing. You can fix them on the spot, without having to "jump" anywhere.
If you drop an entire source file into your project, you may not be in an edit window on that file. (And, of course, that's not standard Eclipse usage.) The simplest way I know do deal with that is simply to "Refresh" the project and look in the Package Explorer view to see whether there are any errors detected (which will happen immediately if you "refresh" a file into a source folder). Double-click on any files which show an error icon and look at the right-hand side of the edit window to see exactly where the errors are.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with...
Unless you are using multiple projects, with inter-project dependencies, I find it useful to close all but the current project on which I'm working. Then the "Problems" view is specific to the current context.
Finally, I'd recommend looking at the Mylin "getting started" page for other hints on how Eclipse can help you focus on the current task.