Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); String name = (String)envCtx.lookup("var1");