Initializing and Running the Component
To do so, you are going to add the code lines in blue typeface to the generated source code.
import java.awt.EventQueue;
import javax.swing.JFrame;
import ilog.server.jsds.IlsDSComponent;
import ilog.server.jsds.swing.IlsDSJFrame;
import ilog.server.jsds.swing.IlsDSJTable;
import java.awt.BorderLayout;
public class MyFrame extends IlsDSJFrame {
/**
* Launch the application.
*/
public static void main(String[] args) {
IlsDSComponent.Initialize(args);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MyFrame frame = new MyFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MyFrame() {
setBounds(100, 100, 450, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
IlsDSJTable ilsDSJTable = new IlsDSJTable();
ilsDSJTable.setLabel("table");
ilsDSJTable.setObjectId("Domain_1");
ilsDSJTable.setViewId("DomainView");
ilsDSJTable.setServerName("network7");
getContentPane().add(ilsDSJTable, BorderLayout.CENTER);
ilsDSJTable.connect();
}
}
6. Initialize the Java data source library with the following code line:
IlsDSComponent.Initialize(args);
This instruction initializes the various parts of the library and processes the command line:
first, the “Java data source part” (
IlsDSComponent),
Then, the “Java component” part (
MvComponent), if necessary,
and, finally, the communication layer (MvTCP by default).
7. Connect it to the server to open the designated view:
ilsDSJTable.connect();
The source code of your Java application now looks like this:
Application Source Code
Your Java client is now ready to run. You can use the compiled server from demo network7, for example. See the README files of the demo for more information on how to compile and run the server with the view you have defined in this tutorial (mainly, you must send the network7 server with the parameter -ilsd <your view file.ils>).
8. Then simply run our Java application:
java MyFrame
You should see the following window, which shows a table view of server object Domain_1, from the Network example:
Table View of Network Server Object Domain_1
Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.