Hi, you're right, the class My5250 uses a few System.exit() calls.
This is a little source snippet, which you may use to bootstrap 5250j yourself ... this way you're avoiding to use My5250j and it's exit() calls. ----------------------------------------------------------- import java.awt.BorderLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.util.Properties; import javax.swing.JFrame; import javax.swing.JPanel; import org.tn5250j.Session5250; import org.tn5250j.SessionBean; import org.tn5250j.SessionConfig; import org.tn5250j.SessionGUI; import org.tn5250j.interfaces.ConfigureFactory; public class ExampleEmbeddedMinimalBootstrap { public static void main(String[] args) { try { System.setProperty("emulator.settingsDirectory", File.createTempFile("tn5250j", "settings").getAbsolutePath()); ConfigureFactory.getInstance(); org.tn5250j.tools.LangTool.init(); final SessionBean sb = createSessionbean(); JFrame frame = new JFrame("TN5250j"); frame.setSize(1024, 768); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { sb.signoff(); sb.disconnect(); } } ); SessionGUI sessgui = new SessionGUI(sb.getSession()); JPanel main = new JPanel(new BorderLayout()); main.add(sessgui,BorderLayout.CENTER); frame.setContentPane(main); frame.setVisible(true); sb.connect(); } catch(Exception e) { e.printStackTrace(); } } private static SessionBean createSessionbean() throws Exception { String system = "127.0.0.1"; // TODO: your IP/hostname SessionBean sessionBean = null; SessionConfig config = new SessionConfig(system,system); config.setProperty("font", "Lucida Sans Typewriter Regular"); // example config Session5250 session = new Session5250(new Properties(),system,system,config); sessionBean = new SessionBean(session); sessionBean.setHostName(system); sessionBean.setCodePage("Cp273"); sessionBean.setNoSaveConfigFile(); sessionBean.setScreenSize("27x132"); sessionBean.setDeviceName("devname"); return sessionBean; } } ----------------------------------------------------------- Regards Martin Am 25.05.2011 15:02, schrieb Arpe, Kevin C: > Hi, > > I noticed in your code you call System.exit() in a few places. > Example: org.tn5250j.My5250.main() > > This makes it difficult to call this method from other Java code. > > Is there a recommended way to spawn new connections using the same virtual > machine? > Example: I want to spawn your app from another app. > > On idea, is call java.exe externally and pass the JAR name. > But I would rather call into your JAR directly -- same virtual machine (VM). > > When I use a basic threading design, it won't work because System.exit() > terminates the VM. > However, I built a very basic SecurityManager to trap calls to System.exit(). > [Source: > http://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit] > Now my solution works... but it is a slight hack. > > Can you please provide the correct API calls... or remove System.exit() from > your code? > > We are big fans here. Keep up the good work. > > Please advise. > Thanks, > Arpe > > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. > > > > ------------------------------------------------------------------------------ > vRanger cuts backup time in half-while increasing security. > With the market-leading solution for virtual backup and recovery, > you get blazing-fast, flexible, and affordable data protection. > Download your free trial now. > http://p.sf.net/sfu/quest-d2dcopy1 > > > > _______________________________________________ > Tn5250j-general mailing list > Tn5250j-general@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tn5250j-general
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________ Tn5250j-general mailing list Tn5250j-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tn5250j-general