Ubiquitous Computing envisions an environment where physical and digital devices are seamlessly integrated. Users can access their applications and data anywhere in the environment. Applications are not bound to any single device and can migrate with the user to different environments. Therefore, application mobility is an important aspect of ubiquitous computing. In this paper, we consider the problem of migrating applications across different ubiquitous computing environments (i.e. across different rooms, buildings or even cities). Migration is a tough problem because different environments have different resources (devices or services) available. The context of the environments may be different as well. Hence, mobile applications must adapt to changing contexts and resource availabilities as they migrate from one environment to the next. We introduce the notion of polymorphic applications, where applications can change their structure in order to adapt to different environments. While the structure of polymorphic applications can change during migration, the functionality and the state of the application are preserved as far as possible. This enables users to perform the same tasks as they move from one environment to the next, seamlessly. We make use of ontologies to ensure that the initial and final structures of a migrating application are semantically similar in terms of functionality and behavior. This paper describes our framework for enabling mobile polymorphic applications.