Session類的構造器是私有的。您可以獲得一個可被getDefaultInstance()方法共享的單一的默認會話: Properties props = new Properties(); // fill props with any information Session session = Session.getDefaultInstance(props, null); 或者,您可以用getInstance()方法創建一個獨特的會話: Properties props = new Properties(); // fill props with any information Session session = Session.getInstance(props, null); 這兩種情形下的null參數都是一種Authenticator對象,它不是在此時使用的。具體信息請參閱其后的“Autherticator”一節。