Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display a byte array as an array of hex bytes or unsigned decimal numbers in the Eclipse Java debugger?

I want to view a byte array in the Eclipse (Helios Release, build id: 20100617-1415) Java debugger as an array of hex bytes (2 digits each) or unsigned decimal numbers? Is that possible? How?

For example, I want to display this:

alt text

...as: 0, 48, 71, 22, 139, 166, ...

...or as: 0x00, 0x30, 0x47, 0x16, 0x8B, 0xA6, ...

(This is a similar question to "How do I display a byte array as a char array in the Eclipse Java debugger?".)

like image 530
Daryl Spitzer Avatar asked Oct 15 '10 04:10

Daryl Spitzer


People also ask

How do you assign a byte array in Java?

Arrays. fill(). This method assigns the required byte value to the byte array in Java.

What is byte array format?

A byte is 8 bits (binary data). A byte array is an array of bytes (tautology FTW!). You could use a byte array to store a collection of binary data, for example, the contents of a file. The downside to this is that the entire file contents must be loaded into memory.

What is byte array size?

The bytearray class is a mutable sequence of integers in the range of 0 to 256.


2 Answers

Not exact what you want but as I know in DEBUG MODE, there is an option for primitive Types (int, long,...).

 Switch to Debug perspective.
 In the Variables view click the "menu" item (triangle item before minimize) and select "Java Primitives...".
 In the Dialog you can choose between Hex view, Ascii view and unsigned (for byte).

Found this, maybe help: Inside the Memory View

On 3.7 (and maybe earlier), go into preferences, type "primitive display" in the filtering area, and choose to display hex values.

like image 155
pinichi Avatar answered Sep 28 '22 07:09

pinichi


Updated answer in Eclipse Kepler 4.3:

In the Debug perspective, the Variables tab will have:

  • View Menu (a downward triangle),
  • Minimize (a line), and
  • Maximize (a window) icons in the upper-right corner.

Steps:

  • Click on View Menu > Java > Java Preferences... to bring up a menu.
  • In this menu select Java > Debug > Primitive Display Options.
  • Check Display hexadecimal values and then click OK.
  • You should now see hex values in brackets in the Variables tab.
like image 44
Thomas Keene Avatar answered Sep 28 '22 06:09

Thomas Keene