William B. Goggins, 87, a retired Navy rear admiral who commanded a battleship in World War II and who later founded a computer and communications company here, died of cardiac arrest Dec. 27 at Fairfax Hospital. He lived in Arlington.

Early in the war, the future admiral was executive officer of the light cruiser Marblehead in the Java Sea. The ship sustained heavy damage in an action against the Japanese on Feb. 4, 1942, and Adm. Goggins was severely burned. He and other casualties were landed on Java while the Marblehead limped home.

By the end of the month, Japanese forces were going ashore on Java, and the American sailors were hidden until they escaped to Australia aboard small craft. These adventures formed the basis of a book by James Hilton and a movie, "The Story of Dr. Wassell," which was produced by Cecil B. DeMille.

From October 1942 to January 1945, Adm. Goggins served at Pacific Fleet Headquarters at Pearl Harbor, Hawaii, as head of the radio intelligence unit. He then took command of the battleship Alabama, participating in actions at Okinawa and against the Japanese home islands.

His military decorations included two Legions of Merit, the Purple Heart and a Navy Unit Commendation, which was awarded to the Marblehead.

His postwar assignments included duty as commanding officer of the Naval Administrative Command of the Central Intelligence Group in Washington, a forerunner of the CIA. He was chief of staff to the naval commandant of the Panama Canal Zone when he retired in 1949. He was advanced to the rank of rear admiral at that time.

Adm. Goggins later did research at Johns Hopkins University and was a staff consultant to the Army Research Association. He also had operated his own firm, the General Kinetics Institute, a computer and communications company.

Adm. Goggins, a resident of the Washington area since 1949, was a native of Republic, Wash. He attended the Naval Academy at Annapolis, graduating in 1919 with the class of 1920. He also saw duty aboard battleships during World War I. He earned a master's degree in electrical engineering at Yale University.

His wife of 59 years, the former Etta Elgin, died in 1981. His survivors include a son, retired Air Force Lt. Col. William B. Goggins Jr. of Bedford, Mass.; a daughter, Jane G. Ryan of Alexandria; a sister, Beatrice Taber of Tumwater, Wash., and six grandchildren.