Earlier this month in a dimly lighted warehouse on the Alexandria waterfront, a passel of teenagers wearing do-rags and oversize T-shirts shook canisters of paint, took aim at planks of wood and started spraying.

Most of the boys were high school dropouts, and some had been involved with gangs or petty crime. But the tagging they were doing had nothing to do with graffiti. They were building boats. The green paint was to mark the chines, or curved wood; white was for keels, or straight pieces; and black was for the rails, which can be straight or slightly curved.

They learned that bit of knowledge in a six-month program run by the Alexandria Seaport Foundation that helps teenagers and young adults who have had trouble with school find a different path to an education.

The foundation was created in 1983 to promote Alexandria's maritime history. In 1992 it began teaching boat building to adults and children, and a year later it began running the program for at-risk teens and young adults. About 220 students have passed through the program.

Boat building is used to prepare participants for work as carpenters and to encourage them to get high school equivalency diplomas through the city public schools' adult education program. This year, the program added a component: teaching the math, science and English skills that a student needs to get GED certification, the equivalent of a high school degree, which is a requirement for entry into the carpenters union.

The program also helps the young adults obtain driver's licenses, open bank accounts and start tool collections.

The national office of the United Brotherhood of Carpenters and Joiners of America accepts any student the program recommends as an apprentice.

The integration of the GED program, which is mandatory, has made class work more relevant and boat building more interesting, said Joe Youcha, the program's founder and the foundation's executive director.

"Before, we were just a shop program, and we weren't taking the time to teach," he said. "Now these kids know why they're here; they know why they need the schooling."

Youcha whipped out a sheet of graph paper and started scribbling figures. "You want to learn a carpenter's trick? If that piece of wood in there is 73/8 inches and we need to cut that in half, you want to know an easy way to do it?"

Rattling out a formula that involved simple division and addition, he quickly jotted down the answer, giving a taste of the geometry, algebra and other math that students learn to apply to boat building. (Youcha is helping to write a math textbook for the carpenters union).

In English class, the students read stories about the sea and write about their work in the shop. In science class, they learn about physics, chemistry, human anatomy and botany.

"They've got to know what sapwood is and what heartwood is and the reason we can't use [sapwood] and the reason it rots and lets water flow through it," Youcha said. "We use practical applications as much as we can, and that way they learn without it being beaten into them."

Wearing dust masks, two boys fed a two-inch-thick plank of white oak into a thickness planer.

Two others listened as instructor Esteban Hernandez, a former student in the program who went on to join the Marines, showed them how to fit a plank onto the side of a 17-foot replica of a Pisquataqua wherry, a historic round-bottomed rowboat from New England.

The current batch of students started only a month ago, but they have already built kayaks with Inuit boat builders at the National Museum of the American Indian and helped native Hawaiian canoe builders with a canoe launch at the Thompson Boat Center in the District.

The boat-building program has three paid instructors and 10 regular volunteers. Two volunteers who were there last week offer specialized knowledge -- Bill Hunley, 81, was chief naval architect for the U.S. Navy, and Bob Squires, 80, was a physicist at Lawrence Livermore National Laboratory.

As a couple of boys looked on, Youcha pointed at the grain on a large, curved board of white oak.

"See the growth rings?" he said, making a fist beside the board. "The center of the tree is somewhere over there."

The boys followed him to where Squires was showing a boy how to fit red cedar floorboards into what will someday be a steamboat for Hunley.

Youcha pointed at an elegantly curved piece of wood with a dark marbled pattern that formed the coaming, or trim, around the cockpit. "This is quarter-sawed oak -- see the vertical grain?" he said. "You can see the flecking. So if any of you guys go into cabinet work, you're going to need to know this."

He ran his fingers appreciatively along the raw wood. "This is going to be gorgeous," he said. "These rays, see how they'll take the varnish differently? So they're going to glow; they're going to be almost translucent."

The apprenticeship program has an annual budget of $440,000, most of which comes from individual and corporate donations and government grants. But a quarter to a third comes from selling the boats that the students build.

The students are now working on a fleet of flat-bottom rowing skiffs for Fletcher's Boat House. They also build custom sailboats, motorboats and "Bevin" skiffs, named after Youcha's late shepherd-mix dog. "The idea was that he had seen so many boats come together and this was so simple that even he could build it," Youcha explained.

A few girls have gone through the program, though this class has none. Sixty-five percent of the students have had involvement with gangs. Most come from Alexandria, though some are from the surrounding area. They hear about the program through their schools, friends or the court system.

"Kids who have been violent offenders have come through the program and turned their lives around," Youcha said. "In the last batch, we had a couple of kids who were gangbangers, but they were still peripheral -- stealing cars, not hard core, not at the center of the gang. So they can leave, and what enables them to leave is work."

Not all the students are dropouts. A.J. Bawazir, 18, graduated from Woodbridge High School in June and is planning to go to college. In the meantime, he said, he gets a lot more out of the program than his other summer job at a clothing store.

"I just wanted to learn something new," he said. "I'm trying to save money to go to college." Bawazir is also attending classes part time at Northern Virginia Community College.

Others have few prospects when they come to the program.

"They're sort of doomed as far as making a good living is concerned," Hunley said. "You can't make a living these days without a high school equivalency." But as journeyman carpenters, they can count on making $60,000 to $70,000 a year, he said.

Even now, the students are starting to fill their bank accounts. The program pays $6.50 an hour to start, with raises for good attendance and behavior.

In return, the students have to make commitments. They pledge to come every day, on time, ready to work. They must dress appropriately (no open-toed shoes, nothing that can get caught in the machines) and respect one another and their teachers.

Eventually, sticking to these rules begins to engender self-esteem.

"I've really seen a change in the guys who came in six months ago," said Kurt Spiridakis, an instructor. "They have a lot more confidence; they're more assertive."

For some, he said, just having a regular place to go to, with adults who are invested in them, makes a difference.

"They've got things that wear them down . . . emotionally and physically," said Spiridakis, a blond, blue-eyed 25-year-old from Sonoma County, Calif. "We try to be a stable presence in their life, stable people who are going to stick to them and stick to our word. We can't take the place of their parents, but we try to get them to buy into us, and we hold up our end of the bargain."

For example, Hunley and Squires pass on a lot of technical know-how, as they did recently with a joint lecture on buoyancy, but they also serve as grandfather figures.

Hunley, a tall, white-haired man who wears a sailor cap and grew up in a family of shipbuilders in Mathews County, Va., regales students with stories from World War II, during which he crossed Germany with Patton's 3rd Army. (Asked why he didn't join the Navy, Hunley explained, "I always figured I could run further than I could swim.")

Jerson Herrera, a broad-shouldered 22-year-old with a black ponytail and goatee, has his own tales to tell. He was born in El Salvador, moved to the United States at age 10 and attended Alexandria public schools until 10th grade, when, he said, "I started thinking school wasn't for me."

Ignoring his parents' pleas for him to finish high school, he started drifting from job to job. "Mostly restaurants," he said. "Restaurants. Construction. Whatever."

It was a hard life. "Every construction site, you got laid off," he said. "The last to get hired is the first one laid off."

Herrera, who heard about the boat-building program from a friend, remembered hearing Youcha speak about it at T.C. Williams High School. He joined the program in January, and this time, school made sense to him.

"You actually get to build stuff that regular people would use," he said. "You get working skills, tool knowledge."

"My parents think it's great," he added. "They think this is the best thing that has happened to me."

Two weeks ago, Herrera was part of the program's first GED graduating class. After the ceremony, he and two other graduating apprentices got into a little boat they'd built and rowed away.

Officials in the program say GED classes are more relevant and interesting when combined with boat-building instruction. "Before, we were just a shop program, and we weren't taking the time to teach," said Joe Youcha, the program's founder. From left, student Xavier Davila, volunteer John Borders and instructor Esteban Hernandez work on a boat in an Alexandria Seaport Foundation program. This year, the program began requiring students to take academic courses with the aim of obtaining the general equivalency diploma.Student James Gaffney in an Inuit kayak he helped craft with Inuit builders from the National Museum of the American Indian.From left, students A.J. Bawazir, Xavier Davila and Eder Romero and welding instructor Scott Juisto. About 220 students have passed through the boat-building program since 1993.Above, Xavier Davila works on a boat. At left, instructor John Nicklow leads students during a visit to the carpenters union school in Upper Marlboro. Students who enter the union can make $60,000 to $70,000 a year. At a graduation ceremony for the boat-building program, Deep Datta, left, James Gaffney, rowing, and Jerson Herrera hit the water in a Finger Lakes trout boat that they made.