Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

wip siva

Ranch Hand
+ Follow
since Nov 03, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by wip siva

hi buddies
i am using Runtime.getRuntime().exec("backup.ini");
this will execute this script file.
inside the file look like this
tar cvf test.tar /home1/backup
this will store all the files from /home1/backup to
test.tar
but while executing through GUI (RMI call) its giving error.
its working but not completely.
but samething if i run from simple java application(server itself) it works fine.
i don't know wheather the problem in RMI or exec();
plz help me in this regard
thanx
bye
siva
17 years ago
hi friend
i did ldd -r libGetBackup.so
its giving like this
warning: ldd: libGetBackup.so: is not executable
symbol not found: printf (./libGetBackup.so)
symbol not found: system (./libGetBackup.so)
wheather the .so file should be in executable mode or what
this is from solaris m/c
plz let me know
thanx
17 years ago
hi friend
thanx for ur reply.
i have set LD_LIBRARY_PATH also.i am working on solaris.
now its not giving this problem while starting the rmiregistry.
now its giving while calling the native function from my GUI.
like java.rmi.server error
and unsatisfiedlinkerror
plz help me in this.
i am in a critical situation
thanx
17 years ago
hi friends.
i am calling a simple c function from java.i created a .so file
from some othere m/c.and i copied all necessary files.while
starting the rmi registry.its trying to load the library.i am getting the follwoing exceptions.
plz let me know the problem.
thanx in advance
Exception in thread "main" java.lang.UnsatisfiedLinkError: no my_lib in java.lib
rary.path
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Error.<init>(Error.java:50)
at java.lang.LinkageError.<init>(LinkageError.java:43)
at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
at java.lang.ClassLoader.loadLibrary(Compiled Code)
at java.lang.Runtime.loadLibrary0(Runtime.java:470)
at java.lang.System.loadLibrary(System.java:778)
at <Unloaded Method>
at com.wipro.osssmart.config.MainServer.main(MainServer.java:39)
$
17 years ago
hi buddies
i have a directory called log.under this i have many subdirectories like
25-07-1997
26-07-1997
27-07-1997
28-07-1997
if i select log from JList

i want to filter and display startdate 25-07-1997
to enddate 28-07-1997
how to do it in java
plz with some code
17 years ago
hi
i am selecting an item from JList.if i select it calls valuChanged method from ListSelectionEvent .but the event
is fired two times.
why its happenings.
plz let me know
thanx in advance
17 years ago
hi buddies
i want to check a file which is present in solaris m/c(remote m/c). its in LAN.
i want to check from my win98.
can any one help with some sample code.
the function should to return boolean
thanx in advance
regards
siva
17 years ago
hi friends
thanx a lot .i got it.
bye
17 years ago
hi friends

i am displaying live data on JTable.i have columns .in one column
if there is any String like " error " i should give the beep sound.
i have two threads one to read the broadcasted data and another
one is to display on the table.
plz help me with some sample code
thanx in advance
17 years ago
hi friends
i am working on swing.i am displaying live data on jtable.data will be
continously updated on the table.(scroll).if i kept open for 30 minutes
it is giving out of memory error.i am running two threads one is to receive the data and another is to put it on the table.
i am removing the firstrow after 500 rows.removing from the tablevector
(for performance).
plz help me why i am getting outof memory error
17 years ago
hi friends
thanx a lot for ur interest.
atlast i have achieved it.
don't mistake me.julie has some sample code.
that's why i asked.
anyway thanx keep in touch
bye
17 years ago
hi buddy
i saw ur reply.thanx a lot.still i am waiting for ur reply.
plz give me the sample. to change the color of one particular
row.
my id is
123knock@usa.net
17 years ago
hi stella thanx a lot.
i can able to change the color of one cell.not the entire row.
badly i need it.i have a demo on monday.plz give me the sample
code .
i just put my code .
and i have one more major bug.whenever the table gets updated by
new data its not repainting properly throwing some nullpointer
exception.
i trying it if u have any idea.plz let me know.
my id is .
123knock@usa.net
thanx in advance.

This is the exception i am getting while updating the table.
Exception occurred during event dispatching:
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java, Comp
iled Code)
at javax.swing.plaf.basic.BasicTableUI.paintRow(BasicTableUI.java, Compi
led Code)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java, Compiled
Code)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java, Compiled Code)
at javax.swing.JComponent.paintComponent(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JViewport.paintViaBackingStore(JViewport.java, Compiled C
ode)
at javax.swing.JViewport.paint(JViewport.java, Compiled Code)
at javax.swing.JComponent.paintWithBuffer(JComponent.java, Compiled Code
)
at javax.swing.JComponent._paintImmediately(JComponent.java, Compiled Co
de)
at javax.swing.JComponent.paintImmediately(JComponent.java, Compiled Cod
e)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java, Com
piled Code)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java, Compiled Code)
at javax.swing.SystemEventQueueUtilities.processRunnableEvent(SystemEven
tQueueUtilities.java, Compiled Code)
at javax.swing.SystemEventQueueUtilities$RunnableTarget.processEvent(Sys
temEventQueueUtilities.java, Compiled Code)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java, C
ompiled Code)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
This is my File
***************
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.LinkedList;
import java.util.Collections;
import java.util.Enumeration;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.ComponentUI.*;
import java.awt.Component.*;
import com.wipro.osssmart.multicast.*;

public class MonitorTablePanel extends OssPanel implements OssEventListener,/*Runnable,*/ActionListener,TableModelListener
{
private boolean test = false;
private OssTable ossTable;
private OssTableModel tableModel;
private DefaultTableModel model;
private DefaultTableColumnModel colModel;
private Vector msgVector,errorVector,appVector;
private thread1 thread;
private thread2 listThread;
private boolean orcondition = false;
private boolean andcondition = false;
private OssPanel btnPanel,lblPanel,tblPanel;
private LinkedList list ;
private JScrollBar scrollBar;
private OssButton btnClear,btnFilter;
private OssLabel lblMonitor;
private OssMainFrame frame;
private Message msg;
private ColoredTableCellRenderer renderer;
// private Object[][] data=null;

//Array of columns and rows
String[] names1 ={"Date", "OssName", "ApplicationName", "ServiceName", "MessageType","Result","MessageText"};
// Object[][] data ={{"","","","","","",""},
//};
Vector data=null;
Vector names=null;
//Constructor for MonitorTablePanel
public MonitorTablePanel(OssMainFrame frame)
{
this.frame=frame;
//Setting BorderLayout for this panel
setLayout(new BorderLayout());
msgVector = new Vector();
errorVector = new Vector();
appVector=new Vector();
data=new Vector();
names=new Vector();
for(int i =0; i <names1.length;i++)>
names.addElement(names1[i]);
System.out.println("vector"+names);
//Instanstiating OssTable
tableModel = new OssTableModel(data,names);
tableModel.addTableModelListener(this);
tableModel.setCellEditable(false);
ossTable = new OssTable(tableModel);
model=(DefaultTableModel)ossTable.getModel();
sizeColumn();
list = new LinkedList();
//Creating a Thread for this panel
thread = new thread1();
listThread = new thread2();
JScrollPane scrollPane = new JScrollPane(ossTable);
scrollBar = scrollPane.getVerticalScrollBar();
add("Center", scrollPane);
btnPanel=new OssPanel();
//setting layout for button panel
btnPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 100,10));
btnClear=new OssButton("Clear","Click to Clear");
btnPanel.add(btnClear);
// add("South", btnPanel);
btnClear.addActionListener(this);
btnFilter=new OssButton("Filter","Click to Filter");
btnPanel.add(btnFilter);
add("South", btnPanel);
btnFilter.addActionListener(this);

lblPanel=new OssPanel();
lblMonitor=new OssLabel("Monitor Application");
lblMonitor.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblMonitor.setFont(new Font("Dialog",Font.BOLD|Font.ITALIC,18));
add("Center",lblMonitor);
lblPanel.setLayout(new BorderLayout());
lblPanel.setBackground(Color.yellow);
lblPanel.add("North",lblMonitor);
add("North",lblPanel);
tblPanel=new OssPanel();
tblPanel.setLayout(new BorderLayout());
tblPanel.add("Center",scrollPane);
renderer = new ColoredTableCellRenderer();
colModel=new DefaultTableColumnModel();
(ossTable.getColumnModel()).getColumn(5).setCellRenderer(renderer);
add("Center",tblPanel);

}//End of COnstructor

/**
* This Method used to Clear all the rows on the Table
* by clicking clear button.
**/

public void actionPerformed(ActionEvent e)
{
try
{
if(e.getSource()==btnClear)
{
model.getDataVector().removeAllElements();
ossTable.updateUI();
}
if(e.getSource()==btnFilter)
{
frame.filterAction(e);
System.out.println("Filter clicked");
}

}catch(Exception ce)
{
ce.printStackTrace();
System.out.println("Clear Table"+ce.getMessage());
}
}

/** This Method to upDate the data on the table
* This will be called when any one the Application is selected from left Panel.
**/
public void updateData(OssEvent event)
{
try
{
if(event.getActionType()== OssEvent.APPLICATION)
{
appVector.removeAllElements();
appVector = event.getData();

}
else if(event.getActionType() == OssEvent.FILTEROR)
{
msgVector = event.getData();
errorVector = event.getErrorVector();
orcondition = true;
andcondition = false;
}
else if (event.getActionType()== OssEvent.FILTERAND)
{
msgVector = event.getData();
errorVector = event.getErrorVector();
andcondition = true;
orcondition = false;
}
else if(event.getActionType()==OssEvent.STOP)
{
orcondition = false;
andcondition = false;
}
//Then it calls the start method
start();
}catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in updateData:"+e.getMessage());
}
}
/** This method gets the Messages as parameter and adds to the vector
* Then the vector added to the TableMOdel by using addRow method.
**/
public void addRow(Message msg)
{
try
{
Vector vector = new Vector();
vector.addElement((String)msg.applicationName);
vector.addElement((String)msg.ossName);
vector.addElement((String)msg.clusterName);
vector.addElement((String)msg.serviceName);
vector.addElement((String)msg.messageType);
vector.addElement((String)msg.errorType);
vector.addElement((String)msg.messageText);
// if(SwingUtilities.isEventDispatchThread())
model.addRow(vector);
ossTable.updateUI();
//ossTable.validate();
}catch(NullPointerException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}

/**
* This Method to set the preferedsize of the table column
**/
public void sizeColumn()
{
for(int i=0; i< ossTable.getColumnCount() ;i++)
{
TableColumn objLeftEndColumn = ossTable.getColumnModel().getColumn( i );
objLeftEndColumn.setPreferredWidth(objLeftEndColumn.getWidth() + 50 );
}
}
/** This Method to start the Thread
**/
public void start()
{
test=false;
if(thread.isAlive())
{
try
{
thread.interrupt();
}
catch(Exception e)
{ }
}
if(listThread.isAlive())
{
try
{
listThread.interrupt();
}
catch(Exception e)
{ }
}
if(list.size() != 0)
{
list.clear() ;
}
if(!thread.isAlive())
thread.start();
}
/** This class Start of thread1
* This thread used to receive the data
* from the hub.
**/
private class thread1 extends Thread
{
private Message preMessage = null;
private Message msg1 = null;
public thread1()
{
}
public void run()
{
while(true)
{
Reciever cl = new Reciever();
//Reading data from OssHub and storing it in a String object
msg1= cl.read();
if(preMessage == null )
{
list.addLast(msg1);
preMessage = msg1;
}
else if( msg1.applicationName.trim().compareTo(preMessage.applicationName.trim()) != 0 )
{
list.addLast(msg1);
preMessage = msg1;
}
else
{
System.out.println("Adding thread1" );
}
try
{
this.sleep(400);
}
catch(Exception e)
{ }
if(!test)
{
if(list.size() != 0)
{
if(!listThread.isAlive())
listThread.start();
test = true;
}
}
}
}
}// End of class thread2
/** This class Start of thread2
* This thread used to put the data
* On the table.
**/
private class thread2 extends Thread
{
//private Message msg;
public thread2()
{
msg = new Message();
}
//Overrided run method from Thread class
public void run()
{
try
{
while( true )
{
try
{
msg = (Message)list.removeFirst();
}
catch(Exception e)
{
msg=null;
}
if(msg != null)
{
if ((msg.applicationName).equalsIgnoreCase(("System").trim()))
{
addRow(msg);
//model.fireTableDataChanged();
}
else
{
if(appVector.indexOf((msg.applicationName).trim()) != -1)
{
if (andcondition == true)
{
if(errorVector.indexOf(msg.errorType.trim()) != -1 && msgVector.indexOf(msg.messageText.trim()) != -1 )
{
addRow(msg);
//model.fireTableDataChanged();
}
else if(errorVector.size() == 0 && msgVector.indexOf(msg.messageText.trim()) != -1 )
{
addRow(msg);
//model.fireTableDataChanged();
}
else if(errorVector.indexOf(msg.errorType.trim()) != -1 && msgVector.size() == 0)
{
addRow(msg);
//model.fireTableDataChanged();
}
}
else if (orcondition == true)
{
if(msgVector.indexOf(msg.messageText.trim()) != -1 )
{
addRow(msg);
//model.fireTableDataChanged();
}
else if(errorVector.indexOf(msg.errorType.trim()) != -1)
{
addRow(msg);
//model.fireTableDataChanged();
}
}
else
{
addRow(msg);
//model.fireTableDataChanged();
}
}
}
}
scrollBar.setValue(model.getRowCount()* ossTable.getRowHeight()) ;
try
{
this.sleep(100);
}
catch(Exception e)
{ }
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in Thread"+e.getMessage());
}
}
}// End of class thread2
//scrollBar.updateUI();
public void tableChanged(TableModelEvent e)
{
try
{
if((msg.errorType).equalsIgnoreCase(("Error Type2").trim()))
{
//ossTable.setForeground(Color.red);
}
else
{
ossTable.setForeground(Color.blue);
}
}catch(Exception a)
{
//a.printStackTrace();
}
}
class ColoredTableCellRenderer extends DefaultTableCellRenderer
{
public void setValue(Object value)
{
setText((String)value);
if(((String)value).equals("Error Type2"))
{

setForeground(Color.red);
}
else
{
setForeground(Color.blue);
}
}
}
}//End of MonitorTablePanel class
17 years ago
hi
i am displaying live data on jtable.i am using addRow(Vector)
method.i used table.updateUI(),table.validate(),fireTableDataChanged() and etc. but still i am getting the
follwing exception.
plz can any one tell me the solution.
thanx in advance
bye

Exception occurred during event dispatching:
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java, Comp
iled Code)
at javax.swing.plaf.basic.BasicTableUI.paintRow(BasicTableUI.java, Compi
led Code)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java, Compiled
Code)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java, Compiled Code)
at javax.swing.JComponent.paintComponent(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JComponent.paintChildren(JComponent.java, Compiled Code)
at javax.swing.JComponent.paint(JComponent.java, Compiled Code)
at javax.swing.JViewport.paintViaBackingStore(JViewport.java, Compiled C
ode)
at javax.swing.JViewport.paint(JViewport.java, Compiled Code)
at javax.swing.JComponent.paintWithBuffer(JComponent.java, Compiled Code
)
at javax.swing.JComponent._paintImmediately(JComponent.java, Compiled Co
de)
at javax.swing.JComponent.paintImmediately(JComponent.java, Compiled Cod
e)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java, Com
piled Code)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java, Compiled Code)
at javax.swing.SystemEventQueueUtilities.processRunnableEvent(SystemEven
tQueueUtilities.java, Compiled Code)
at javax.swing.SystemEventQueueUtilities$RunnableTarget.processEvent(Sys
temEventQueueUtilities.java, Compiled Code)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java, C
ompiled Code)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
17 years ago
hi friends
i want to change the color of a particular row dynamically.right now i can able to change all the row.how to capture a particular row and change the color dynamically.
plz help me with some example
bye
17 years ago