We present three-dimensional simulations with nested meshes of the dynamics of the gas around a Jupiter mass planet with the JUPITER and FARGOCA codes. We implemented a radiative transfer module into the JUPITER code to account for realistic heating and cooling of the gas. We focus on the circumplanetary gas flow, determining its characteristics at very high resolution ($80%$ of Jupiters diameter). In our nominal simulation where the temperature evolves freely by the radiative module and reaches 13000 K at the planet, a circumplanetary envelope was formed filling the entire Roche-lobe. Because of our equation of state is simplified and probably overestimates the temperature, we also performed simulations with limited maximal temperatures in the planet region (1000 K, 1500 K, and 2000 K). In these fixed temperature cases circumplanetary disks (CPDs) were formed. This suggests that the capability to form a circumplanetary disk is not simply linked to the mass of the planet and its ability to open a gap. Instead, the gas temperature at the planets location, which depends on its accretion history, plays also fundamental role. The CPDs in the simulations are hot and cooling very slowly, they have very steep temperature and density profiles, and are strongly sub-Keplerian. Moreover, the CPDs are fed by a strong vertical influx, which shocks on the CPD surfaces creating a hot and luminous shock-front. In contrast, the pressure supported circumplanetary envelope is characterized by internal convection and almost stalled rotation.