Java application profiling / tracking - java

I have a closed source Java application for which vendor has provided APIs for customization. As I have no other documents, i rely completely on the API's javadoc.
I want to trace what methods are actually called in different classes for a particular use case. Is there any way to do that with eclipse?

Most profilers (like YourKit and JProfiler) support Eclipse integration.

JadClipse is a plug-in that allows you to decompile classes using jad, decompilation is available at the time of debugging.
There are some limitations, jad doesn't support java-5, and try catch functions don't always align nicely, but it can give you a good idea of whats going on inside.
See this thread too is-jad-the-best-java-decompiler

You need to use eclipse TPTP (http://www.eclipse.org/tptp/)
Personally I would use VisualVM or Netbeans profiler if possible

Java Decompiler has an Eclipse plugin, supporting Java 6, and works pretty well to decompile source and see what's inside the class files while debugging.

Related

How to implement a java IDE with Java

I would know how to implement a Java IDE using Java language.
My IDE should :
compile, run and debug a source code.
import or export file from a directory.
allow generating code from class diagram.
allow modifying Java text editor.
allow generate Swing source code from, I mean it will offer a ability of drag and drop, then it generates source code.
it gives possibility to save, delete, undo and redo.
it support JUnit, maven and Ant.
So, I ask about technologies that will help me to realize this Java IDE. How to implement this IDE?
Except for the "drug" part which I am not sure of, I can tell it is not a trivial amount of work and of course I'd use the Java's GUI API
http://en.wikipedia.org/wiki/Swing_%28Java%29
Will not be sarcastic like others around here so I will try to give a short answer.
Despite there are some very very mature Java IDE's (Eclipse,NetBeans,INtelliJ ,JCreator,Codeguide etc) around it is your right to do another (who know someday maybe better then existing ones).
This being said you can do it
Swing (here you have to start from
zero)
use RCP Eclipse
Netbeans platform
QT it might be a solution
etc.
All of this support drag and drop and have support for creting class diagrams...
I warn you it is not easy....not easy at all.
Eclipse was audited recently and it has apx. 46 millions line of code
Good luck !
I'd safe yourself loads of time and just use Netbeans out of the box. Does everything you've listed and more. It's also free and has a module architecture to allow new functionality to be added fairly easily.

How to optimize the code in my java application

A java app I have been writing for the last few years has now become quite bloated and I am conscious of including unused code etc…
I know for css and javascript you perform code cleanups and compact the code etc.. does anything like this exist for java?
For some reason developers always dismiss the importance of the java garbage collector.
This should help: http://www.devdaily.com/java/edu/pj/pj010008
Linda
The fact that you are quoting css as an example for an language that enables code cleanup, tells me that you are probably new to java.
Java has one of the Richest set of tools for performing code cleanup (or general re-factoring). There are two ways to perform code cleanups. One is to use Static code analyzer and other way is to have an instrumentation support to monitor your running programs.
There are many static code analyzer in the market and the some of the best ones are open source. If you are a serious Java developer then you cannot get a better IDE than Intellij ( no, I do not get paid by them..). They have one of the best code analyzer tools integrated with an IDE. This link should help you.
You do not have to use Intellij to get the same kind of code Analysis. You can use PMD and FindBugs plugins for any leading IDE. Among all the code analyzers, I believe these two are the best to dig out deep problems in the code and not just superficial mistakes. ( like formatting Issue).
These tools will help you clean up dead codes, find probably bugs and unclosed objects. You should also customize the tools based on your requirements, but that comes later.
Once you have identified and fixed all the problems identified by your static analyzer, then you need to monitor your program for potential problems like Memory Leak. Some problems are only found during runtime.Java had an inbuild instrumentation mechanism called JMX and almost all major Server Vendors have exposed it. You could also use Jconsole, that could act as an abstraction layer over JMX.
Have you considered using any code coverage tools to determine exactly what portions of your code are getting executed? Take a look at EMMA:
http://emma.sourceforge.net/
Optimizing and cleaning up are two separate issues. You can start on both using Eclipse.
Take a look at these sections of your Eclipse configuration:
Window > Preferences > Java > Code Style > Clean up / Code Templates / Formatter
And:
Window > preferences > Java > Compiler > Errors/Warnings
You'll find a lot of handy features for flagging and even automatically fixing things that are commonly considered to be bad code.
For performance optimization, you might try the Eclipse Test & Performance Tools Platform Project.

debugger for C/C++ and Java

I mainly use vim, but I really like the debuggers used in modern IDEs such as Netbeans, Visual C++, and Eclipse and I am wondering if there were any debuggers like those except in a standalone program? I tried using gdb, but it seems that debugging will take a lot longer using a command line. I also tried ddd, but it was a little frustrating to use since it would not display some complex structures with arrays. I really like how the debuggers in the modern IDEs allow me to just click on the down arrow to view what are in my arrays something which I do not know how to do in gdb or ddd.
You could have a look at:
http://code.google.com/p/jswat/
It's a standalone java debugger. I'm afraid it doesn't support C++ debugging.
Try Nemiver, which is a standalone graphical debugger for C and C++. It is openly developed as part of the GNOME project and uses gdb underneath.
http://projects.gnome.org/nemiver/
For windows you can use windbg. It is very good.
Don't know about Java, but for C++ you don't need an IDE to use a debugger. It is perfectly possible to code with vim and use a standalone debugger, such as windbg or gdb. In fact, that's what I do all the time.
Use Eclipse. You can easily create an Eclipse project around existing code, and still use VIM to edit your files while using Eclipse to debug.
IntelliJ is free now so it should be a good choice, I've found it to be easier to use than Eclipse but I haven't used Eclipse too much. A few features like smart complete (Ctrl+Shift+Space that lets you import/complete constructors), independent run/debug consoles that can be viewed at the same time, hotswap debugging and autosave help me save time on day-to-day programming tasks. However, there's a lot of support and plug-ins for Eclipse since it's always been open source so it really depends on what you want to do.

Practical Java - Development Environments

I've had several classes - university level - on Java.
However, what these classes lack is some practical approach to Java - or, to programming as a whole. Things you can only learn in a business.
However, since I am not allowed to use Java on the workfloor, I don't get to learn this now - even though I would like to.
So I guess what I'm asking for is any number of plain have-to-know Java resources. Things concering, for example, what Ant is and why and how to use it; using revision control systems from your IDE; standard Java libraries you would use often ... Anything that would help with actual software development, really.
As some side information, I've been using Eclipse for about four years now, and I feel at home there.
I have a system that works fairly well for class assignments and for projects as well. Firstly, I create one Eclipse project per class. This way I can re-use classes from previous assignments. You can also customize your classpath by adding another project as a library.
I use the Maven plugin for Eclipse M2Eclipse. Not only does this give you the ability to search for libraries and add them easily but the exec:java plugin is an easy way to execute your code from the command line. It's helpful because when it executes your code, it uses a classpath that includes all linked Maven dependencies. If you aren't using external libraries, you might not need Maven but I've found it to be helpful to learn in preparation for the job market. It's fairly simple to start with plus there are a ton useful plugins for open source projects.
Next, for revision control I recommend Subclipse. You can get a free SVN account with a single login from Unfuddle.com. Link that up to your Eclipse environment and Import your project.
When I want to get a particular class specification, I go to Sun's Java documentation.
Another excellent resource that will certainly give you the reference material (searchable!) to answer any java question would be this torrent containing ~100 ebooks on Java, sorted by directory on various topics (like Ant, Eclipse, or Swing).

What are some good plugins for developing Java in VIM?

I love vim, but not having things like IntelliSense/Code completion from Eclipse makes it pretty difficult. I know, I know, I should be able to look at method signatures and java docs for the API I am interested in using. I'd love to, but I'd like it to be accessible from my fingertips instead of having to browse the source tree manually or have a JDK reference handy.
What plugins would make this easier?
I tried eclim for a while. It was pretty good, basically it uses eclipse in the background as a kind of engine and provides a plugin to let you use all of eclipses goodness through vim.
http://eclim.org/
Don't write Java in Vim — put Vim inside a Java IDE:
IdeaVIM for IntelliJ
viPlugin or Eclim for Eclipse
jVi or ViEx for NetBeans
I love Vim, but using an IDE for Java is the only way to stay sane. A decent Java IDE will:
Show invalid syntax or type errors
Show missing JavaDoc
Manage import statements for you
Highlight unused methods and variables
Safely perform powerful refactorings such as moving methods or renaming classes -- (no, search and replace doesn't cut it, I promise)
Reformat your code automatically or on-demand
Vim can't do the above, but you can use all the Vim keybindings in a program which does.
I use Eclipse + Vrapper. Enables the vi dual mode editing we all know and love. <ESC>
Completely free and lightweight. The goal is to have the comfort and ease which comes with the different modes, complex commands and count/operator/motion combinations which are the key features behind editing with Vim, while preserving the powerful features of the different Eclipse text editors, like code generation and refactoring.
While eclim is another alternative, I feel eclim takes over Eclipse and vrapper doesn't.
Check out the JDE plugin for Vim. It provides Java omni-completion and a documentation viewer (among other things).
I use the javacomplete.vim plugin for omni-completion for java. It's a very nice script: it also shows the method signatures on top of the omni-completion. The downside is that it is a bit slow, but it has worked fine for me otherwise. Eclim might be better ut I haven't tried it yet so I can't comment on it.
I've also used the jcommenter.vim plugin for generating javadoc comments. It can parse method signatures and automatically add the relevant #param foo fields and such.
For the API searching I would suggest on overriding the K key on normal mode. It searches man pages for the keyword under the cursor, but the behavior can be overriden by setting the keywordprg variable. See this thread for an example.
Other scripts which I've found very useful (not specific to Java development): NERDCommenter, AutoClose, snipMate, Align.
There's an IntelliJ VIM plugin as well. Plus, IntelliJ is released an open-source, free version.
Vim is not an IDE replacement. But very specific additional tool. With Vim you should only do small-fast tweaks while the main development is going under Netbeans/Eclipse/IDEA.
One more time. It is a Bad Bad Bad idea to turn Vim into Full IDE. Why? It won't be so fast. And thus won't be so pretty.
Here is scenario. You have opened Eclipse or whatever to edit your current task. And in 10 minutes you have to switch to another Task which is kind of urgent. The task is to tweak a little a maven or an ant built script and/or some deployment perl/python/groovy scripts.
How much time will it take to reload Eclipse to work on a new 5 minutes task and switch back?
But if you are Vim guru you can handle this in seconds. You can change one file and run Ant/Mvn within Vim.
And this is the power of Vim. You can change and check one file in no time no matter which extension it has: java, groovy, c++, makefile, bash, c#, etc.
This will be an uphill battle. There is so much knowledge about your program built into Eclipse, that I expect you will eventually have to reimplement it all to be happy.
Any particular reason you cannot just decide you like the built-in editor in Eclipse?

Categories

Resources