In this paper we introduce a novel scheme for portable CPU accounting and control in Java, which is based on program transformation techniques at the bytecode level and can be used with every standard Java Virtual Machine. In our approach applications, middleware, and the standard java runtime libraries (i.e., the Java Development Kit, or JDK) are modified in order to expose details regarding the execution of threads. This paper presents the details of how we reengineer Java bytecode for CPU management, including the strategies developed for transforming the JDK itself in a fully portable way. Categories and Subject Descriptors D.3.3 [Programming Languages]: Language Constructs and Features—Control structures, Frameworks; D.2.8 [Software Engineering]: Metrics—performance measures General Terms Management, Performance, Reliability, Security, Languages Keywords Java, Resource Management, Bytecode Engineering, Program Transformations