Check out the US Military’s most powerful cannon and the way it works. The canon mechanism is based on the principle of homopolar motor: a pair of parallel conductors (the rails) are fed by an electric current. The projectile is placed making contact with both, to close the circuit. The current that is produced interacts with the strong magnetic fields generated by the passage of electricity through the conductors and this accelerates the projectile linearly in the direction of the rails.
The original idea of this device was to use it to shoot projectiles at high speed to destroy targets. However it is difficult to use as a weapon due to the enormous amount of energy required to operate with a minimum of efficiency and because the space occupied by the power supplies and capacitors used to generate the magnetic field makes it very difficult to transport For the infantry. Even so the United States Navy announced a test done on January 31, 2008 in order to equip their ships with this type of weapons.