Intellij, open two projects at once - java

This is not one of the many questions about having two projects in the same window, like eclipse. What I want to ask is, is it possible to open 2 projects when you click one. Here is an image to describe what I want to do:
So when I press one of the projects in the red rectangle that it opens both in the rectangle, because I always need a server and a client running at the same time, so I was thinking, maybe there is a way to automate this process and just click one of the two and it opens two.

This is from the Webstorm docs, but it also works for IntelliJ Idea. I have set the option to "Confirm window" so that Idea asks me every time I want to switch to another project whether I want it in a new window:
Changing the project opening policy
In the Settings/Preferences dialog ⌃⌥S, go to Appearance and Behavior | System Settings.
In the Project opening area, select the project opening policy.
Confirm window to open project in: This option is selected by default. WebStorm displays a dialog where you can choose to open the project in a new window, reuse the existing window, or add the new project to the currently opened one.
Open project in new window: Select this option to silently open each new project in a new window.
Open project in the same window: Select this option to silently close the project opened in the current window and open a new project in it.
(Screenshot: GoLand 2022.3.2)

Use CLI. Add /path/to/intellij.app/Contents/MacOS/idea to your PATH.
idea ~/dev/a; sleep 1; idea ~/dev/b
Didn't work for me if I didn't sleep.
With JetBrains Toolbox the executable is in a strange place so I use this config in my ~/.bashrc. You have to update the version number when installing new versions in the toolbox.
export LATEST_IDEA_VERSION_NUMBER="ch-0/173.3531.6/IntelliJ\ IDEA\ 2017.3\ EAP.app"
export JETBRAINS_TOOLBOX_ROOT="${HOME}/Library/Application\ Support/JetBrains/Toolbox/apps"
export LATEST_IDEA_VERSION_CLI="${JETBRAINS_TOOLBOX_ROOT}/IDEA-U/${LATEST_IDEA_VERSION_NUMBER}/Contents/MacOS/idea"
alias idea="open -a ${LATEST_IDEA_VERSION_CLI}"
For other platforms see: https://www.jetbrains.com/help/idea/opening-files-from-command-line.html

Use can use this script do open all projects in background tasks
#!/bin/bash
# Run a command in the background.
_evalBg() {
eval "$#" &>/dev/null & disown;
}
# in some cases is necessary open the application before projects
webstorm && sleep 1;
_evalBg "webstorm /home/user/development/projects/first";
_evalBg "webstorm /home/user/development/projects/second";
This script is assembly with informations provided by executing shell command in background from script questions. All merits to the original author.

After long due now, IntelliJ Idea now supports multiple windows from IntelliJ IDEA 2022.2.2 (Ultimate Edition), earlier we used to add project as module, but that’s not the right way. Follow these steps your life would be so easy.
Steps to follow to open multiple windows in IntelliJ IDEA
Download latest version of IntelliJ IDEA from here.
Once download, restore default setting using below steps:
File > Manage IDE settings > Restore default settings
Now when you open a new project you will see this window:
Reference: CodeDaily

Related

Intellij doesn't show run button

Intellij doesn't show run button even if that file is in src folder.
Maybe do you know what to do?
P. s. It's strange because that file used to show run button but after recloning git repository it just doesn't show any more.
Right click on src directory and select option Mark Directory As > Sources Root.
There is an Intellij bug that will result to an intermittent disappearance of that little tiny green run button on the left side of the source code (on same column where the red circle breakpoints are). Yes, you can right-click on the mouse and can do the run via the menu, BUT we love that tiny green button so bring it back!! From time to time, i see this green friend and then suddenly it vanish mysteriously and comes back again. I did all, such as rm -rf .idea and other weird stuff, but no explanation has ever been achieved to explain the vanishing green button and it's sudden re-appearance intermittently.
I am drafting this answer, because all of the above answers seems to claim that there is a logical explanation of the intermittent disappearance of our little green friend and that a sequence of steps exists to make our little green friend re-appear, when in fact, there is no such steps and we just have to accept this is a bug to save the remaining hairs in our scalp.
In my case Run/Debug buttons disappeared for all projects after updating from IDEA 2019.2 to 2019.3. Tried checking Sources Root, Invalidate Caches, Run/Debug configurations etc - no luck. Only restoring Run/Debug action group helped:
Right click on main toolbar (where the button disappeared) > Customize Menus and Toolbars... > select Run/Debug > Restore Run/Debug.
I got the same problem with intellij 2019.3 and 2020.1 and found the solution here : https://youtrack.jetbrains.com/issue/IDEA-228180.
Basically, in the IDE the buttons run/debug and the error detection in the code were missing.
The fix was to disable the plugin 'Gradle' (I don't need it anyway) :
Settings > Plugins > Gradle and click disable and apply.
After restarting your IDE it should work
I had this issue when building a microservice with SpringBoot.
I added a new microservice into the root folder and I could not run it.I am using Maven.
Step:
Open pom.xml
right click and select "Add as maven project"
It should resolve it immediately but you can reload the IDE if it does not update immediately.
IDE: Idea 2021.2.3
Build tool: Gradle
I removed the .idea and reimported the project from the Gradle source. Worked fine after.
Another reason could be the Highlighting Level set to None, it should be set at least to Syntax.
First, make the folder as source root.
Second, make sure you set the project’s sdk correctly. For example, if you set the sdk correctly then import java.util.Scanner can be analyzed by IDEA.
Tip:
try not setting the SDK to IDEA’s bundled JDK. I set the project’s SDK to JDK 11 bundled by IDEA at first then found it couldn’t resolve import java.util.Scanner. Setting to JDK 16 which is installed by the OS’s package manager solved this problem, then the “run” button showed up.
If IDEA can index a java file then the file icon will show with a small “c”, indicating a java class. If not, the file icon will show with a small “j”, as this problem’s image shows, indicating a java file which IDEA doesn’t index.
In my case there was a plugin (springboot helper) which I had to disable.
Reinstall the IDE, it solved my problem.
I also applied all these methods but it still didn't work so I stopped my window firewall and allowed access for this application. I don't know how it worked out for me but it just got displayed on top of my screen that window defender firewall has stopped some of this app's features and there was an option to allow so I clicked on it and it now works just fine.

Eclipse (SWT composite): How to run and where is build?

I am new to Eclipse and Java programming having mainly worked with Microsoft Visual Studio.
I installed Eclipse (Kepler 4.3) with no issues along with WindowsBuilder and SWT.
I created a new project adding in references to SWT, both WindowsBuilder JARS, and resty. Into the project, I created a new package and selected a SWT composite. I gave appropriate names.
The GUI designer came up with no issues. I added in a couple of controls. The idea is to create a hello world application, display that application, and build it. Eclipse has automatically build checked.
Okay, the IDE in designer view shows the GUI of my Hello World application and the source view the source, so no problems there.
I press Run, and the first time I had to select a run configuration, which I selected EclipseStarter. There was not many options. I click on run and nothing happens.
If I go to the project's bin package folder, I see a file with a ".class" extension.
Why does pressing Run|Run (Ctrl+F11) do nothingness? There is a brief hour glass showing, but then nothing after that.
How do I launch the application from within Eclipse?
Is the generated ".class" file the correct runtime? I double click on that and Windows does not know what to do with it?
The end platform will be CentOS, but Java as I understand things, should be platform independent, so my Hello World application should run on my Windows 7 Pro box just as nicely. (I did not try CentOS yet) as I want to see it work on my desktop and know what file to copy over.
I think you selected the wrong option EclipseStarter.
Try running it as a Standalone Java Application.
It is a Standalone Java Application that you're building, right?
(I mean, the analogue of a Windows Forms App in .NET)
1. I guess because you selected the wrong type.
2. Ctrl+F11 is for Running it, F11 only is for Debugging it.
3. The class file has to be run by a JVM, Windows cannot run it directly,
it is not anything like a native executable or like a .NET assembly
(which Windows 7 knows how to run). But as you're using Eclipse you
already have a JVM.
The solution is multi-fold.
I had to delete Eclipse and install the 32-bit version of everything. That simplified life, as 64-bit caused issues running.
Create a new package
From the toolbar, select "Create new visual classes" drop down. Select "SWT" --> "Application windows".
Create the application window
Press the play button, 8th icon having selected the package first.
That enabled to run my Hello World on Windows. The output is a .java.
I still have a problem running from the command line, but that is a different issue.
Summary: My main issue was creating a SWT application window first and that I should have 32-bit for everything.

Non-existing MySql message error

I have to build a Decision Support System, but dont have much experience in Java. So after I connected to MySql with Eclipse (with Connector/J) eclipse started to mess up my other projects. Now, when i try to run other projects in eclipse (that are not related to MySql, ex. Guessing Game) the following error message apperars:
Launch configuration DocsConnectionPropsHelper references non-existing project MySql connection test.
Can anyone help me to resolve this problem please?
UPDATE. it seems that when i press "RUN" elcipse is not running the project that im working with, but other
Your update indicates the issue is actually running the wrong project. To avoid that you may want to close projects you're not working on (right click them in package explorer and select close).
If you do need multiple projects open then when clicking the run icon (which defaults to re-run whatever was ran last among your open projects) make sure you have open in the editor window something that can be ran (and is from the project you want to run).
Then click the drop down arrow to the right of the icon. This will open up a small menu with options to change your build configurations or how it should run your program (i.e. as an application or on a server).
To solve the problem:
-click right botton on the project package you want to work on (run)
-choose Run As
-choose Run Configurations...
-choose DocsConnectionPropsHelper - if in the Project box you see not correct title just remove it. Also remove anything what is in the Main Class box.
-click Apply
-the best option is to close Eclipse and reopen it to make sure that all the settings were configured
It worked for me. Hopefully it will work for you too.

How to read SVN Tortoise Command from Java application

As I am doing an application which requires to do all the operations like checkout, checkin, commit, rollback and etc.. Please can any one give command line options for SVN tortoise?
As I understand, you want to implement a Java application that calls Subversion commands. I think there are 3 options you could go with:
(and best one): Use SVNKit as a pure Java implementation of the Subversion API in Java. So you have there Java classes and methods and can do anything you want (if you understand how to use it correctly).
You could use JavaHL which is more difficult to install, but then comparable in usage to SVNKit. However, the implementation differs on different platforms (no Java-only implementation), so depending on your usage scenario, it may not be an option.
You could just start svn commands from Java, but I would not do that.
There is enough information available on the internet how to do the base commands with SVNKit, so just give it a try.
TortoiseSVN is a front end to subversion. See the Version Control with
Subversion book for a list of all the command line commands. Appendix E. Command Line Interface Cross Reference of the TortoiseSVN documentation provides another source for the commands.
You will get enough help from internet about tortoise SVN.
You can create a repository in system folder or in Eclipse.
These steps will install SVN plug-in in Eclipse.
Open Eclipse.
Go to Help Click Install New Software
Click “Add” button
Put “Subclipse 1.2.x (Eclipse 3.2+)” under Name and “http://subclipse.tigris.org/update_1.8.x” under Location:
Click ok
Select subclipse selection option in selection window. Select all
Click next button n/a
In review the items to be installed window. Click next.
Licenses must be reviewed and accepted before the software can be installed. Click I accept radio box. Click finish.
During installation eclipse may ask for the validity of plugin being installed. Click ok
After installation. Restart Eclipse.
Create SVN Repository Location in Eclipse
In the navigator perspective, right click and choose new
Choose SVN > Checkout Projects from SVN
Select the option to create a new repository location.
Fill in the location of the SVN repository (https://link-to-repository) and click next. Project info is loaded.
It may ask username and password or validation of repository site certificates. Click “accept permanently”.
From RAD File menu, choose Import to display the import manager. Choose Checkout Projects from SVN. Click Next
Select Use existing repository location option to enable the Next button.
It will load all projects from repository in “trunk”. Expand trunk menu option
Select all the projects one by one to import in projects in workspace.
Why would you not call svn commands directly from java? I mean can't we open a command prompt using a RunTime instance and passing the svn command to it.Is that a bad idea?If yes, what are the disadvantages?

Debugging with Eclipse using multiple windows

I usually run a dual-monitor setup, so I have two Eclipse windows open for the same workspace, displaying different files. When I'm debugging and a breakpoint is hit, Eclipse switches to the "Debug" perspective, but it also shows the file/line where the breakpoint is in both of my windows. This occurs even if the file containing the breakpoint was open in one window but not the other (before the breakpoint was hit).
This is really annoying.
How can I have Eclipse only show the file containing the breakpoint in one window? Ideally, it would choose which window based on where the file is open already. If it's not already open somewhere, I don't really care which window it pops up in.
You can create another workspace and in that workspace create a new project from the same src code (same files in file system) of the one in your current project in your current workspace.
That would let you stop on one breakpoint without the other window stopping their too.
Notice that after you make some code modifications in one project you'd have to refresh the other project for those changes to apply in it.
Eclipse switches to the debug perspective for all windows the debug perspective has been opened once (i.e. the little icon on the right top corner is available). If you close that perspective (switch to another perspective is not sufficient), it won't switch to it anymore on that window.
At least, that's the behaviour I observed on Kepler (I know, that question is older but just came across, maybe it still helps someone).
This worked for me:
In Window->Preferences->Run/Debug->Launching->Launch Configurations enable "Apply window working set(s)"
Personally I find this more efficient than creating two workspaces.
Closing the Debug perspective (righ-click on the little icon on the right top corner) worked for me.
I'm using Oxygen and I have the following settings in the Run/Debug Preferences:
Open the associated perspective when launching: Never
Open the associated perspective when an application suspends: Prompt
Maybe you select the sources for Debugging by "File System Directory" instead of by "Java Project". To change this go to Run=>Debug Configuration=>Add Sources=Button: ADD...=>Java Project and select your Projects.
Make sure, that the added sources are found first by moving them to the top.
To disable multiple debugging in multiple windows in eclipse, go to Windows > Preferences > Run/Debug and uncheck Activate the debug view when a breakpoint is hit

Categories