Eclipse commands - java

What is the difference between Ctrl + Shift + R and Ctrl + Shift + T?
Do we have a blog with all eclipse tips/shortcuts?

Ctrl-Shift-R: Find a resource, which can include XML files, Ant scripts etc.
Ctrl-Shift-T: Find a type, regardless of the filename. (This can be handy if you're looking for a nested type, or basically if you don't want to see anything other than types...)
For Eclipse shortcuts, there are lots of Eclipse keyboard cheat sheets. From the search, I like this PDF, this shorter list, and this list with more explanations.

Ctrl+shift+R is for Open Resource, it
searches for all types of files in
your projects.
Ctrl+shift+T is for
Open Type, it looks for Java classes
and interfaces.
A great feature of the Open Type dialog is that you can search for say DataInputStream by typing DIS.

T : open a type (Java artifact)
R : open any file (any resource)

Ctrl-Shift-T will find Java types including those imported in JAR files without source (e.g. Java standard API)
Ctrl-Shift-R will only find Java types present as source code, but will also find other kinds of source files such as Text and XML.

To see all key bindings look under Window -> Preferences -> General -> Keys.

Also, Ctrl+Shift+L will show you which keyboard shortcuts are active right then.

Blatant advertising coming up:
If you like these two search options, you would love nWire. It is an Eclipse plugin for Java developers which provides, among other things, much stronger search. You get to search as you type for methods, fields, packages... practically everything you have in Java.
As for some more tips, I have written the following article in EclipseZone. I really suggest adding EclipseZone to your RSS feeds reading list. Lots of tips and good stuff there.

Related

Translate English to some other Language in RAD or Eclipse

I have written comments in English in my Java files but now my client wants it in Spanish, So is there any tool/Plugin available in RAD or ECLIPSE IDE to convert all the comments in other language. I am using google translator to convert comments manually.
I'm not aware of any plugin like that. First, I would make sure the client really really wants this. Doing an automatic translate of highly technical text will not give a very good quality. I question if they will be usable at all, do a test translate of a couple of comments first to get approval.
If they really want something that is usable someone with language and technical skill would have to manually translate everything, which would take time/money.
But, if I had to do it, I would take the idea from this answer to automatically launch a web browser from Eclipse, and use the URL to google translate, https://translate.google.se/#en/es/${selected_text}, should work.
If the codebase is large and the comments can be easily found, such as a javadoc, I would write some script to automatically handle this. Google translate has an API you can use. See REST API doc
Every now and then a developer has to work on a code base that is in a language that is unknown to him. In this case, he would need to copy variable, class, method names to Google Translate to see what they actually mean.
The Source Code Translation in Eclipse tries to help such developers, by providing a popup with the translated words, when hovering the mouse over them. The plugin is able to handle compound words or phrases that use camelCase or underscore "_" as separation methods.
For the plugin to work, a properties file containing the word to be translated, and the translation needs to be created and added from the Preferences section of the plugin.
Add this URL to your Eclipse Installation to reach this solution's update site.
https://github.com/Testehan/TranslationPluginInstall/raw/master
In External Tools Configurations
Location : ${system_path:cmd.exe}
Arguments : /C start "" "https://translate.google.com/#en/fr/${selected_text}"

Eclipse - is it possible to jump to a particular package?

Say i'm looking at some file, and i'd like to see if there are similar files in a different package. I don't really know what the different files might be called - they were coded by different people, so could well be named differently.
I do know they're probably in a package of roughly the same name - for example, if i'm looking at a file in the com.sandwiches.ham.artisan package, and i think there should be a similar (although, in this case, sadly unrelated) file in the com.sandwiches.avocado.artisan package, what is the fastest way to jump to said package and check it out?
I'm fed up of scrolling through reams of artisan sanwiches, its making me hungry.
Well, no matter what, you are going to have to do some typing. There is a Go-to navigation item for packages, its just not bound to any quick keys. To bind it to a key combination of your choice, do the following:
Eclipse->Preferences, and type in Keys as your filter.
Search for the Go To Package command, click on the Binding entry field, and type whatever keys you want to use for the keybindings (in my screenshot I have it set to Command-Shift-0). Then click OK to save and close the preferences dialog.
After that, typing your chosen key bindings will bring up a package explorer that lets you type in whatever package you want and navigate to it.
From the Breadcrumb (press Alt+Shift+B to open it) it is quite quick to navigate your way through the sandwich menu ehm I meant packages structure...
Ctrl + Shift + R its a good shortcut to find files in every package in your proyects, i use it everytime... hope it help...

How to generate a PDF from JavaDoc (including overview and package summaries)

I have written extensive JavaDoc documentation on my application, and added lots of useful info at overview.html and package.html files (including links on the former to illustrations in doc-files/). Maven's Javadoc plugin nicely uses the standard javadoc tool to generate the classic JavaDoc frameset, but now I need to generate a PDF with the whole documentation.
AurigaDoclet generates very pretty PDFs, and I was able to make DocFlex work also. However, both ignore my overview.html and package.html files (tried both inside and outside Maven - the PDF will be a once-only thing, since I'd rather have the HTMLs on the long run).
Does anyone know how to make AurigaDoclet recoginze my non-Java files? Or, alternatively, another to generate a decent-looking PDF from either the source code or the JavaDoc-generated HTML?
Nailed it. After trying all the possible tools to generate straight from the source, I returned to HTMLDOC. It is not JavaDoc-aware, but it is so well built that a few tweaks are enough to make it generate a pretty usable PDF.
Here goes a step-by-step description of how I did it:
Download the software on the releases page;
Generate your traditional HTML docs in your preferred way (Ant, Maven, command-line javadoc - your choice);
The GUI is nice, but adding all files manually can be cumbersome, so just create a .book file with Document Type set to "Web Page", add one of the HTML files from your generated javadoc's root folder (e.g., overview-summary.html, anyone will do, it's just for reference on step 5). On the Output tab select the PDF format and set a name for it, and add other options to your heart's content (logos, colors, lots of cool stuff here). Save this project (say, myjavadocpdf.book) and close the GUI
Generate a list of all HTML files in your javadoc. I did it with Cygwin's find command (my DOS/cmd shell days are long over), but you can do anything you want, as long as you get a file list. In my case a find . | grep html$ | sort -r > files.txt did the trick;
For Windows users, dir /s/b *.html > files.txt should do the same (but keep in mind you may have to replace \s with /s if they appear like so on the next step).
Open the .book file generated on step 3 in your favorite pure text editor (as a programmer you should have strong opinions on that, so will keep my opinions to myself - NOT ;-) ) and append the list generated on step 4 to this .book file (it keeps the list of files at the end, making life really easy). Don't forget to fix the relative paths, if needed with a global search/replace (that's why you needed at least one file added on step 3 - to see which file path pattern htmldoc expects);
Now you should sort the files in a convenient order. I put my overview first, then package descriptions and each class, then the full index, and everything else at the end. Remember that any file you delete will become an external (hence broken) link, so choose wisely;
Save your .book file and re-open it on HTMLDOC. Voila: all files added and sorted. Click on generate. That's it!
You may want to fiddle with images (hint: use HTML width/height, not style/css). In the end, the resulting file is surprisingly good: nice looking and fully navigable for internal and external links. Impressive when you consider that the tool is not Java(Doc) aware at all...
EDIT: software is now free from original author; updated links, thank you #mohammed
According to the Sun JavaDoc FAQ, there's a couple of options -- mostly free, with one or two commercial offerings as well. Check it out at http://java.sun.com/j2se/javadoc/faq/index.html#print.
AurigaDoclet fails to process package.html.
For a fix see my comment at https://sourceforge.net/projects/aurigadoclet/forums/forum/339169/topic/1572199/index/page/1
If this question was bumped anyways, I can use this to link my ltxdoclet project.
This creates from the source (by being a JavaDoc plugin) documentation in LaTeX format, which you then can pass through PdfLaTeX to produce a PDF.
Optionally it also can include pretty-printed source code.

Java's equivalent to php.net?

Where can I find useful resources to Java.
all Java functions and syntax explaining (like php.net)
mac widgets with all functions gathered (like php function reference)
Would be great if you had links to very good resources/tutorials to share.
you should start with the Javadoc
JavaDoc in CHM format for easily searching
http://www.allimant.org/javadoc/index.php
Javadoc is an invaluable reference as already said
I think you should just get Eclipse or your favorite IDE and add the Javadoc to the build path of the jar
EDIT:
Window\Preferences\Java\Installed JREs
Select the JRE
Press Edit
Javadoc URL: point to the URL
Shift + F2 should take you to the appropriate function definition
, and i must say it is very productive =]
Just use the auto-completion feature of your editor.
In Eclipse: Write "[name of your object].", Press [CRTL]+[SPACE] and then read the javadoc of the suggested functions/methods.
Java API Documentation explains all classes and methods.
Java2s.com has very good examples for Java

What are the common tricks in eclipse when working with jsp files?

I looked through this list of “Hidden” features/tricks for Eclipse?", but it doesn't have anything for web-developement (jsp). A very useful list of tricks for a general eclipse user!
I work with jsp pages in Eclipse Ganymede, and I would like to find out a list of shortcuts commonly used to facilitate development. I always seem to struggle with the following, among other issues:
always traverse a directory tree to find a file (no Ctrl-shift-t just like java classes)
search is always ends up with either ctrl-f or searching the entire project
I would appreciate if you guys list tricks for eclipse, specifically for web-development (jsp/tomcat)
I am a noob, so don't hesitate to list anything even if you think it is TOO NOOB!!!
Thanks
my favorite:
ctrl + shift + r will open a resource dialog like the type dialog
Refer 30 Useful Eclipse Keyboard Shortcuts for Java Programmers for more.
First of all, be certain you use the Java EE version of Eclipse.
Edit:
Use Ctrl-Shift-R to locate a given resource (also known as "file").
You can use F3 on java identifiers in <%...%> to go to their definition.
The best tip I can give you is to learn JSF or similar so your JSP files only contain tags, and not java snippets.
I use the MyEclipse plugin. I have been very happy with it and it has a lot of jsp support.
MyEclipse
Get the Web Tools Platform plugin. I think it's included by default in the Jave EE edition of Eclipse, but you can also install it separately. To see if it's installed in your Eclipse, open the Help|About screen and look for a "WTP" icon.
It doesn't provide any web-specific shortcuts, but it will give you syntax highlighting and some auto-completion for HTML and CSS files, and for JSP files, enable many of the navigation features that you're used to from Java editing. (Such as Ctrl+Space to import a class and F3 to see its definition.)
Regardless of whether you have WTP installed or not:
Use Ctrl+Shift+R to open files; this works much like Ctrl+Shift+T for opening classes.
Use Ctrl+H to search the whole of your project, or parts of it. If you pick the "File search" tab, you can specify file patterns (such as *.jsp) to search in. If you click on a folder in the Package Explorer, you can select "Selected resources" from the "Scope" box to search only in that folder (and its sub-folders).

Categories

Resources