Arriving by plane
Bristol Airport. This is the closest airport to Bath. The best way to go from Bristol Airport to Bath is to take the direct A4 bus (which runs approximately once every 30 minutes with journey time of just above one hour). You can purchase the ticket with the bus driver, and can buy a return ticket (to be used within 3 months). The bus stops along the way, but you can stay on the bus until its final stop, just across the street from Bath Spa train station.
An alternative way is to take the Airport Flyer bus to Bristol Temple Meads train station and then take a train to Bath (the overall journey time is approximately 50min).
London Heathrow. There are trains going from Heathrow airport to Bath (via London Paddington). This is the easiest way to go to Bath from Heathrow, but can sometimes be expensive.
Another option is to take the RailAir bus from Heathrow to Reading train station and then take a train from Reading to Bath (overall journey time of about 2 hours). The bus picks up passengers in Heathrow from the central bus station (easily accessible by foot from terminals 2 and 3) and from terminal 5. If your flight arrives at terminal 4, you need to take the Heathrow Express or a bus to terminals 2,3 or 5.
A third possibility is to take a direct bus from Heathrow Central Bus Station to Bath (journey time of approximately 2.5 hours). Make sure to check the timetable since most of the times the trip is much longer or the schedule is not very convenient.
London Gatwick, London City and Birmingham International airports are further away but could be an alternative. From them, you can take (non-direct) trains to Bath. Approximate journey time: 3 hours from Gatwick and 2.5 hours from London City or Birmingham.
Arriving by train
The main train station in Bath is Bath SPA.
Information regarding the trains can be found at http://www.nationalrail.co.uk
Getting to campus
The University of Bath is on the top of a hill. The bus lines U1 and U18 can take you from the city center to campus; you can purchase the ticket directly on the bus.
Walking from the city center to the university is possible, but it includes a long and steep hill and takes around 45min. The other direction (from the university to the city center) is a rather pleasant and scenic walk when the weather is nice.
Further information, including campus maps, can be found in the university website.