Etiqueta: eclipse

Create JAR with Eclipse

The best way to distribute java applications is using a JAR file that is run with the java VM.

To create a JAR with eclipse we have to go the project explore and click with the right button and on the menu select “Export

On the next window we select to export as a runnable JAR file

After this, we need to select:

  • The execution entry point (Configured launcher)
  • The export destination
  • And the option to package the jar with libraries

Java Remote Debug with Eclipse

Usually when we develop an application we can replicate the environment where we are running the application to verify that the application works correctly.

Sometimes this is not possible due to some special circumstances (network, special hardware, amount of data, client restrictions,ect..) when we find an error while in this special circumstances, we need to do a remote debug.

Launch the application on the server

First we need to run the application on the server. We can generate a jar file using this instructions.

We need to launch the application with some special arguments:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=1088,server=y,suspend=n -jar hello.jar

Connect Eclipse to the application to debug

To connect to the remote process we need to indicate the host where to connect and the port.

After this, you can debug the application as it was on your local machine.

If you can’t open any port of the server and you only have ssh access this article can be useful

Best Eclipse keyboard shortcuts

Eclipse is one of the most used IDEs to develop in Java. Sometimes Java can be complicated or slow to navigate througth the code, but sometimes this happens due we don’t know how to use all the capacities of the IDE

Search a class

It’s possible to search a class using the shortcut Control+Shift+H

Search a method on the class

When we have a class and want to go to a method we press Control+O this will open:

Search the usages of a method

If we want to see where a method or a function is used ,pressing Control+Shift+G Eclipse will search all the usages of the function and show on a result search

Plain search on the code

This should be our last opion when we search on the code but if we press Control+H we can search plaintext on the code

Go to line

If we want to go to a specific line we can press Control+l

© 2024 Another dev

Tema de Anders NorenAmunt ↑