IntelliJ IDEA Settings
It was painful when the first time I switched from MyEclipse to IntelliJ IDEA. Well, it was because the source codes were a mess though.
2.1 Move Maven repository location.
I want to manage my profile folder structure, so I have changed the location of many of them. After the IntelliJ IDEA installation, I found there are two directories under my profile folder. One is called “.m2” and the other one is “.IntelliJIdea”.
After many tries, I failed to figure out a way of moving them. Although there are some environment variable settings in the option, none of them work for me.
The location of them seems to be related to the location of your Desktop folder. But this is only my assumption.
I found this after that I installed Windows 8 and redesign the layer of my profile storage. I like the new layer which seems cleaner so I copied them to Windows 7. Then I found this issue was accidently solved – both .m2 and .IntelliJIdea are moved to a location that I liked.
2.2 Cannot display Chinese.
Well, this is the most issues I met. I strongly request Jetbrains the compilation.
At first, I should point out that this almost happens in every IDE. Either you will met them in the application, or in the source codes, or in your compiled program.
The first thing you need to do to choose a correct font which support your language. As the simplified Chinese, many mono-spaced fonts doesn’t have this support. Well, although they seems OK in many Windows application when displaying Chinese, the OS has done a great job for you under the surface.
If you choose a appropriate font, in most cases, your source code should be displayed without malformed text. If it doesn’t work, then check out the below section.
2.2.2 File encoding
The second thing you could do is configuring your application. You could find them in IntelliJ IDEA -> settings -> file encodings.
You should keep the properties as default because this is a standard.
This will solve the second common error – File encoding.
Besides this, look at the bottom. You will find a way to specify the encoding for a single file.
After the above steps, your source code should have been display completely correctly. If it still doesn’t work, I believe it is the problem of this file.
But what you see is not always as same as your get. Not like MyEclipse, the encoding settings for single files not automatically considered in the process of compilation. This is reason why you got malformed text in the program. Then we switch to the next approach.
The best way to solve it is to do it in UTF-8 (without BOM) at the beginning of your work. However, by default, it is in ANSI which is usually GBK for Windows CHS (ANSI is different regarding to your operating system).
To take remedial measures, for MyEclipse, you need to change all your project file encoding setting to GBK or UTF-8 or any other encodings. Just all your files. In MyEclipse, your won’t need to do this though. You just need to turn a switch for this single file.
Well, I strongly request Jetbrains enhance the compilation module to make it more smarter. I processed a chunk of codes and they were wrote in different encodings. It’s fine when in MyEclipse but I have to convert them when in IntelliJ IDEA.
There may by a way to get around with by using Eclipse compiler. But I failed to find a manual to make it work. I found a help from Ecplise (Compiling Java Code) which tells how to add settings for specified files but it didn’t work for me. If anyone knows how to do it, please tell me.
2.2.3 Wrong codes
If above doesn’t help get out of the mess, then I believed it is because of your codes. The Internet has examples for this and I am not going to place them in this article since it is not doing with this IDE.
2.3 Module dependency.
Configure project framework supports
Right click. You will see a menu called “add framework”. If you don’t have the libraries of some commonly used such as spring, hibernate, you may try the “add framework” approach. It will download them for you.
Also under the module dependency tab. You can choose to add user libraries, jars, etc.
2.4 Edit the file
2.4.1 Where is the function list?
Look at the left bottom. There is a structure windows.
I didn’t find it. Yes, I did!! :(
Ctrl+Shift+N to search file.
Ctrl+Shift+F to search text.
2.7 VCS undo add (or Move versioned files to unversion)
The fist case is that the file you just added was not versioned and it was not in the repository.
To make a undo is doing the revert. There is no second solution.
The second case is that the file has been versioned and you want to be moved to unversion category.
You have to mark them for delete. For SVN, svn rm –keep-local [file]
2.5 Tomcat deployment.
The URL is configured directly in “Run/Debug Configuration”, which is combined with Server page and Deployment page.
There are 5 things you need to do.
First, add a artifact in Project Structure. You can choose the output directory here. By default, it is $PROJECT_DIR$/.out. The IntelliJ IDEA maps the URL of your application to here. You can change it to the ordinary way which is putting the output under webapp folder.
Second, add an application server in Run/Debug Configuration.
Third, select the server you added.
Fourth, select artifact you added in the Deployment tab. You can keep the Application context as the default, which is just a /. You can also change it you any name your want. But I recommend that set it as same as the name of your artifact. For example, if the artifact is EG, then the context is /EG.
Fifth, go back to Server tab. You find the startup page is different from the first time you see it. If your doesn’t have configuration for the start page somewhere. Then you need to append it here. If the URL is …/EG, then you append your page to the URL which becomes …/EG/your page.
2.5.1 Error running Default: Unable to open debugger port: java.net.SocketException “socket closed”
This error is popped out because there are something wrong with the JVM.
I came across this error because I modified the catalina.bat. I added a JAVA_OPTS configuration in this file. It seems IntelliJ IDEA doesn’t like this approach and perhaps it more prefers configuring it in its settings (After all I see such a space).
After I removed it, this error disappeared.
2.5.2 Tomcat dynamic updates.
Some articles say I need plugins to support this feature. But it seems no. In my situation, when I modified something, the IDE does update the resource and I can see the modification I made from the browser.
But just in case, if you don’t get the dynamically updating, you can select “update classes and sources” option.
Sometimes, you may get to need manual operations when something is wrong. Make the project.
2.5.3 Simultaneously debug multiple application via a single Application server instance.
Won’t be able to do this as what can be done in Eclipse. At least I failed to find it.
Keywords for look up: