In a physically inaccurate but close enough explanation:
F = MA
2AS = V^2
Where V and M is the velocity and mass of the projectile respectively, A is the (initial) acceleration, F is the force in newtons provided by the spring, and S is the distance travelled.
For the purpose of this explanation acceleration is assumed to be constant (which generally isn't, as force dissipates due to expansion or friction or other reasons else) and the pressure is enough to push the BB out of the barrel before it leaves the barrel.
For both real rifles and airsoft rifles, the barrel length determines how much acceleration the projectile can experience due to air pressure behind it, where as long as the air pressure is sufficient the projectile will be constantly pushed out of the barrel until it leaves the barrel.
With a shorter barrel, the "acceleration corridor" is shortened, thereby the BB experiences a shorter period of acceleration and could only be launched at a slower speed than when it was being launched through a longer barrel. Hence your observation of the resulting Joule count being lower than what it had been is a completely normal phenomenon.
To compensate, you can either use an even more powerful spring or use washers, both with the intent in increasing the amount of energy (hence BB acceleration) provided to the BB and compensate for the reduced length, but this comes at the cost of increasing wear and tear of parts due to extra stress, as well as making it harder to pull the bolt backwards.
In general if Joules is a major concern to you it's advisable to use a longer inner barrel instead.