java

Howto change a default Eclipse project to an Eclipse Java project

To change a default Eclipse project to an Eclipse Java project you can follow the steps below.

  1. First close the project in Eclipse (right-click project folder > close project)
  2. Open the .project file in a text-editor outside Eclipse
  3. Add the Java builder and nature to the .project file
  4. Save and close file
  5. Open project in Eclipse and it now is a Java project

Example:
Original .project file

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>A project</name>

Java memory usage

We all know that Java is a memory hog. This page aims to give you an idea how much it actually hogs without using a profiler.
Primitive types
A reference to an object is in this listing also considered to be a primitive type.

  • boolean: 1 byte
  • byte: 1 byte
  • char: 2 bytes
  • short: 2 bytes
  • int: 4 bytes
  • long: 8 bytes
  • float: 4 bytes
  • double: 8 bytes
  • reference: 4 bytes

Objects
Each Java object uses the following:

  • 8 byte Object overhead

Determine uncompressed size of GZIP file

For some applications it is useful to determine the uncompressed size of a file that has been compressed by the gzip algorithm. From the command line this can be done by using the -l option of the gzip program. But this is less straightforward using the Java API's. The GZIPInputStream class does not provide a method to query the original file size. However the information is present in the GZIP file for files that were originally smaller than 4 Gb and can be extracted.

Syndicate content