Recent advances in wireless technology allow Java-enabled devices, such as Smart Phones and PDAs, to create mobile ad hoc networks, over which distributed applications can be executed. Although Java shields the programmers from the heterogeneity of the hardware platforms, a common middleware architecture is needed to support a cooperative execution environment in these networks. In this paper, we present a portable runtime system for Smart Messages (SMs), a middleware architecture based on execution migration, that we designed and implemented on top of an unmodified Java virtual machine. To facilitate portability, we have designed a lightweight migration mechanism based on Java bytecode instrumentation. This mechanism is suitable for mobile ad hoc networks where limited bandwidth and mobility impose constraints on the amount of data transferred. The experimental results for applications executed over wireless networks of HP iPAQs demonstrate the feasibility of our portable runtime system.