For an n-body simulation, Newtons Law of Universal Gravitation is the main thing. You'll be doing all the actual simulation math using orbital state vectors, and then convert that to Keplerian elements or whatever other human-readable format you want.

This page has the equations you'll need. Except that page assumes only a 2 dimensional orbit, but adding a third dimension should be fairly self-explanatory. It also assumes you're only simulating one body orbiting one other body (one being of negligible mass). So, firstly, you'll want to apply the force (

**not** the acceleration) in opposite directions on both objects.

Secondly, you're probably wanting to simulate the interactions of more than two objects, so for every object you'll want to apply NLUG with every other object in the simulation (I recommend pre-calculating an array containing every valid pair of object interactions, eg {[earth:moon], [earth:sun], [earth:satellite], [moon:sun], [moon:satellite], [sun:satellite]}. With n objects, you'll have nC2 interactions, presuming you don't use any limits to avoid having to calculate negligible influences, eg plutos gravity on a satellite in LEO). The way you'll want to do this is, every timestep of the simulation, calculate the force imparted on every object by every other object, add up the force vectors applied to each object, and then at the next tick (not before), calculate the total change in velocity and position from that net force vector and apply it.

That gets you the orbital mechanics part. You'll probably also want to be able to maneuver your spacecraft. The method here is broadly similar. You'll define a unit vector in the direction you want to thrust towards, and then multiply that unit vector by the thrust your engine produces in Newtons. As before, you'll add this force vector to the net force vector from before, and calculate acceleration, velocity, and position from that on the next tick. Also, because engines consume propellant, subtract the propellant consumed each tick from the vehicle wet mass (calculate this propellant consumption using the ISP formula).

I can post my code if you're interested (it uses a few non-standard Java libraries for display though)