Page 1 of 1

Is there any way to get the EEPROM size of a Java Card?

Posted: Wed Mar 06, 2019 4:59 am
by xiaoxiancai
Is there any way to get the EEPROM size of a Java Card?

Re: Is there any way to get the EEPROM size of a Java Card?

Posted: Thu Mar 07, 2019 11:30 pm
by bigWhite
hello,

You can get it from the card supplier, or use the following API function to get.

Code: Select all

/**
	 * Obtains the amount of memory of the specified type that is available to
	 * the applet. Note that implementation-dependent memory overhead structures
	 * may also use the same memory pool.
	 * <p>
	 * Notes:
	 * <ul>
	 * <li><em>The number of bytes returned is only an upper bound on the amount
	 * of memory available due to overhead requirements.</em>
	 * <li><em>Allocation of CLEAR_ON_RESET transient objects may affect the
	 * amount of CLEAR_ON_DESELECT transient memory available.</em>
	 * <li><em>Allocation of CLEAR_ON_DESELECT transient objects may affect the
	 * amount of CLEAR_ON_RESET transient memory available.</em>
	 * <li><em>If the number of available bytes is greater than 32767, then
	 * this method returns 32767.</em>
	 * <li><em>The returned count is not an indicator of the size of object which
	 * may be created since memory fragmentation is possible.</em>
	 * </ul>
	 * 
	 * @param memoryType
	 *            the type of memory being queried. One of the
	 *            <CODE>MEMORY_TYPE_*</CODE> constants defined above. See
	 *            {@link #MEMORY_TYPE_PERSISTENT MEMORY_TYPE_PERSISTENT}.
	 * @return the upper bound on available bytes of memory for the specified
	 *         type
	 * @exception SystemException
	 *                with the following reason codes:
	 *                <ul>
	 *                <li><code>SystemException.ILLEGAL_VALUE</code> if
	 *                <code>memoryType</code> is not a valid memory type.
	 *                </ul>
	 */
	public static short getAvailableMemory(byte memoryType)
			throws SystemException {

Re: Is there any way to get the EEPROM size of a Java Card?

Posted: Fri Mar 15, 2019 5:45 am
by BirdKing
Note, the return value type of getAvailableMemory() is short. It max value 32767. If getAvailableMemory() returned 32767, you should called this method again to check wether the card has more memory.

Re: Is there any way to get the EEPROM size of a Java Card?

Posted: Fri Apr 12, 2019 5:58 am
by xiaoxiancai
Can anyone share some code about getting the EEPROM?
thanks.