High-precision spectroscopy on the 2 3S?2 1S transition is possible in ultracold optically trapped helium, but the accuracy is limited by the ac-Stark shift induced by the optical dipole trap. To overcome this problem, we have built a trapping laser system at the predicted magic wavelength of 319.8 nm. Our system is based on frequency conversion using commercially available components and produces over 2 W of power at this wavelength. With this system, we show trapping of ultracold atoms, both thermal (~0.2 ?k) and in a BoseEinstein condensate, with a trap lifetime of several seconds, mainly limited by off-resonant scattering.