Java7
Posts tagged eclipse
Using Maven behind an office proxy
Sep 3rd
Right! The same thing you did in home didn’t work for your office setup (though you couldn’t not blame that it could be due to your office PC setup not being blazingly faster than your home PC, but that is not the “root cause” 90% of the time =p)
Chances are, when you are in the office, you are behind a proxy, and whether you are aware of changes that have been made to your internet browser by your network or PC administrator, you need to configure Maven accordingly too, for Maven to work in a snap.
Check your proxy settings
Here is how you can verify your proxy settings, information which you would need for putting it into Maven’s settings.xml.
Go to Internet Explorer (Sorry i that am using IE 6 for this demonstration, this is really for the benefit of those who have survived the big bang haha ><) > Tools > Internet Options > Connections > LAN Settings.
Take note of the host (singproxy.as) and the port number (80), you will need this for later.
Change your Maven proxy settings
Go to your Maven home directory, locate the file settings.xml in the conf directory.
* By modifying this file directory, we are changing the settings globally for users of this local machine, which is probably 99% of time what you would like to do, however if not, you can make changes to this at a user level.
Open up settings.xml, locate and edit the proxy settings. Using the host and port number obtained from the above step, edit, save, and close the descriptor (settings.xml).
<proxies>
<proxy>
<id>my office proxy</id>
<active>true</active>
<protocol>http</protocol>
<username>chinboon</username>
<password>password</password>
<host>singproxy.as</host>
<port>80</port>
<nonProxyHosts>*.gij|*.omnia|*.as|10.*|*.local|*.quest.com|*.toadsoft.com</nonProxyHosts>
</proxy>
</proxies>
Verify changes made
In the last step, you could verify the changes have been made successfully by going back to do what was initially stopping you, these errors should go away. For my situation where because of the proxy settings, Maven was unable to down the index from the public repository, and this problem went away for me.
Maven is able to download and index my local m2 repository. :)
Still having problems?
If you are using Eclipse, then chances are that you are using the embedded Maven installation managed by your plugin exclusively, and it can become troublesome to maintain.
Check if you are using an embedded Maven installation, add the external installation that you have installed by yourself, i.e. the one at C:/maven/xxxx. Verify that the settings.xml is the one you have edited in the above steps.
:) Have lots of fun playing with Maven!
Point Eclipse IDE to another JDK / JRE
Aug 19th
Toda. You thought your life is gone away for the next few years using Ganymede or worse.
Sure you have to work with Java version 1.4.2, but that doesn’t mean you cannot use the latest IDE from Eclipse (3.7 Indigo as i am writing). In fact i have many portable and installed versions of JDK on my machine.
Starting with Eclipse Helios, the developers have made JDK 5 a minimum requirement for JVM. This way, they stopped providing backwards compatibility with Java version 1.4.2.
Maybe you could have other reasons for not using the default JDK that Eclipse points to, or downloads with, such as for the reason of trying out the Oracle’s new friendly licensed JRockit JDK. For these reasons, there are many ways to “point your Eclipse IDE to another JVM”, and the one that i will illustrate here is fairly simple and quick.
1. Go to your Eclipse Installation
(If you can’t find it, right click on the shortcut icon that you use to launch the program > Properties > Find target)
2. Locate the file eclipse.ini and open with your favorite editor
3. Insert a new option -vm above the -vmargs option.
-vm C:/Program Files/Java/jrockit-jdk1.6.0_26-R28.1.4-4.0.1/bin/javaw.exe
Note that this step is crucial in that the -vm option must be above the -vmargs for it to work.
Under the -vm argument, insert the installation location of your JDK that you wish to point your Eclipse to.
4. Save the file and start Eclipse!
Help Eclipse IDE recognize .ejb and other custom files you have
Aug 11th
Right, there are .ejb files and they most likely belong to the EJB 2.x era.
However opening them in Eclipse shows them as just plain text, and even with associating .ejb with the Java Editor, you are most likely not able to step through the codes with syntax highlighting and features you would get if you were editing a .java source file.
Go to Windows > Preference
Search for “File Association”
Choose the “Content Types” link option.
Add to Java Source File tree the “*.ejb” file association and you are done.
Strangely in Eclipse Indigo (3.7), i need to restart the IDE to let this settings take effect.
General Eclipse IDE Shortcut Keys / Mnemonic
Dec 23rd
Eclipse by far one of the more prominent and comprehensive integrated development environment in the Java namespace especially, and it is beneficial to learn a few mnemonic keyboard shortcut strokes to work more efficiently.
Download default key bindings PDF from Eclipse
Toggle between enclosing curly brace { … }
CTRL + SHIFT + P
Jump from Method to Method
CTRL + SHIFT + (Up or Down Arrow)
Rename File / Resource
Conveniently rename a file name, i.e. from “HelloWorld.java” to “Expert.java”.
ALT + SHIFT + R
Open File / Resource
Conveniently open a file without browsing through the package or project explorer provided you have the file name in hand.
CTRL + SHIFT + R
Move File / Resource
Move a file to another folder.
ALT + SHIFT + V
Save All Files / Resources
Save all edited / unsaved files or resources currently open in editors.
CTRL + SHIFT + S
Organize Import (s)
Let the IDE sort out all imports for you based on your build path and order so you no longer need to manually write your “import java.util.StringTokenizer;” when you use them in your code.
CTRL + SHIFT + O
Navigating Through Editor
Conveniently tab between opened source editors that you are working on to the left or right directional.
CTRL + PgUp
CTRL + PgDn
Create New File / Resource
CTRL + N
Format Code
Conveniently format and standardize your codes on a per file basis.
CTRL + SHIFT + F
Close Editor
Conveniently close a code editor.
CTRL + W
Close All Opened Editors
Conveniently close all opened code editors.
CTRL + SHIFT + W
Jump to Method / Variable
Go directly to method or variable.
CTRL + O
The following commands are known to work on Eclipse 3.6 Helios.
History
25 December 2010 – Added “Save All Files / Resources”
27 December 2010 – Added “Close Editor” and “Close All Opened Editors”
10 January 2011 – Added “Jump to Method or Variable”
27 July 2011 – Added “Toggle between enclosing curly brace { … } ” and “Jump from Method to Method”













