Wednesday May 21, 2008

BTrace BOF at JavaOne

I had been in US for the past two weeks and got a great opportunity to talk about BTrace at JavaOne BOF alongwith Sundar .  A great tool for dynamically tracing any running VM on the system. Btrace is being provided as a plugin to visualvm and I came up with a simple UI tool with some useful tracing and profiling info. Here are some snapshots of my UI based tool.

 

 

 

 

 


Thanks,

Kannan

 

Tuesday Apr 22, 2008

Making a non-focusable Window focusable

I recently came across another issue from a customer where an awt Window component was not getting focus even when requested.

java.awt.Window or javax.swing.JWindow class is typically used by customer for creating customized popup menus or tooltips or as a splash screen (We now have SplashScreen class introduced in java.awt package in 6.0).

Scenario:

     A Window component is created with lots of awt Label components inside it where each Label component is treated as a menu item
     It's well documented that for a Window to be focusable, its owner (either a Frame or another Window object) needs to be showing on the screen.
    In this case, the customer had a Frame as its owner but still couldn't make the Window focusable. Why?


 

 Reason:

    There is one more condition for a Window component to be focusable that users may not remember and is documented somewhere in the middle of the AWT  Focus specification.

    These are the wordings in AWT Focus Specification:

      "Every Window which is not a Frame or Dialog, but whose nearest owning Frame or Dialog is showing on the screen, and which has at least one Component in its focus traversal cycle, is also focusable by default. "

       Since customer's Window contains only Label(s) and a panel (none of which are focusable by default), the window is not focusable and hence even adding keylistener to the Window object has no effect. 

Solution:

     There are two solutions to this:
      1. Call Window.setFocusable(true)  OR
      2. Reset the focus traversal policy of the window to ContainerOrderFocusTraversalPolicy.

      The first one is much simpler I believe.

Thanks,
Kannan 

Thursday Jan 10, 2008

Post keyevent to system event queue (AWT)

I recently came across an issue from a customer where an attempt to redirect a keyevent to another component (by posting it to the system event queue) resulted in an infinite recursion of the event getting posted.

 
Consider a simple scenario as below:

 
final EventQueue eventQ = Toolkit.getDefaultToolkit().getSystemEventQueue();

TextField tf = new TextField("This is a test"); tf.addKeyListener(new KeyAdapter() {
   public void keyPressed(KeyEvent ev) {
       KeyEvent keyevent = new KeyEvent (
          applet, ev.getID(), ev.getWhen(),
          ev.getModifiers(), ev.getKeyCode(), ev.getKeyChar()
       );
     System.out.println("keyPressed: " + ev.getClass());
     eventQ.postEvent(keyevent);
    }
});

Warning!  Running the above code may generate the keyPressed message on console infinite times.

Reason:

     Note that the keyevent on the textfield is being redirected to an applet. Users may normally expect the keyPressed event of the applet to get called as a result of this (assuming applet has implemented KeyListener) but that may not really happen in reality. In awt implementation, the keyevent is always sent to the focus owner. In this case obviously TextField is the focus owner at the point when keyPressed event is called. So even though an attempt is made to redirect the event to an applet, awt (internally) will post the event back to the focus owner (in this case TextField) and hence results in an infinite recursion.

Conclusion:

     Never post key event to a component until you are sure that the component is the focus owner

Solution:

     We strongly encourage developers to use KeyEventDispatcher (a keyevent preprocessor) or KeyEventPostProcessor (post processor) to handle such cases and redirect the event directly to the targetted component without posting it to the system event queue.
  

Thanks,
Kannan

Friday Dec 21, 2007

JavaFX animation (continued)

Another typical bouncing ball kind of application that I have come up with. Nothing fancy about this application. I have written the application in both JavaFX and Java just to see as to what it takes to come up an application with the same output on both these languages.

Similar to my earlier sample on Solar System simulation, there are a few attributes made configurable with some keypresses. You will find instructions on those at the top left of the application

In order to compare the output, run both the apps from two different terminals. JavaFX script occupies the first half of the screen and the java app occupies the other half. Running both of them simultaneously would occupy the fullscreen.

 Attaching screenshot of the combined application:

 

The script and java program are at:

StarField.fx  and StarField.java


Thanks,

Kannan

 

Saturday Dec 15, 2007

jhat queries from command line

 There are several articles available on jhat and its usage

 http://java.sun.com/javase/6/docs/technotes/tools/share/jhat.html

jhat typically requires to you to run the server from a console and launch a web browser to walk through the heap dumps and run various OQL queriesThere maybe a lot of console (non-UI) based developers wanting to run queries or walk through the heap dump from command line and maybe redirect the various results to a file, thereby staying away from the browser. This could also be useful in cases where the heap dumps are quite huge and the browser UI takes a lot of time to load giving a "browser hang" impression to the user at times.

I have written one such tool that I currently call as JQuery and facilitates performing most of the operations from command line that you would normally do with mouse clicks on the browser

The tool covers most (if not all) of the common functionalities and infact interacts directly with jhat for every heap data output that you look for.

Note that the tool currently dumps output in html format and depending on the needs, I can make it dump output in text format for better readability.

 How to run the tool:

- Preqrequisties:  You need to have jhat server running on a heap dump obtained using jmap

 


- Compile and run the below JQuery class and connect to jhat server (see java JQuery -help for details)

JQuery.java

- Once you are connected, -help <enter> should give you list of commands that you can use to walk through heap dumps and/or redirect the output to a file

 

 

Would appreciate any comments about the functionality/improvements of this tool.
 

Thanks,

Kannan

 


 


JavaFX animation


[Read More]

Sunday Mar 11, 2007

JMX + assistive technologies for visualizing AWT events

Jean-Francois Denise has written an excellent blog for visualizing AWT events on a targetted application at:
http://blogs.sun.com/jmxnetbeans/entry/jmx2awt_mbean

The approach requires a very small modification in the targetted application in order to deploy the MBean:

AWTEvents mbean = AWTEvents.getDefault();
ManagementFactory.getPlatformMBeanServer().registerMBean(mbean,new ObjectName(":type=AWTEvents");

If the targetted application is not to be touched at all but still achieve the same goal as in the above blog, assistive technologies could be used:


So assuming I write a JMX agent as below:

import javax.management.\*;
import java.lang.management.\*;

public class AWTEventAgent {
    private MBeanServer mbs = null;

    public AWTEventAgent() {

        // Create an MBeanServer and HTML adaptor (J2SE 1.4)
        mbs = ManagementFactory.getPlatformMBeanServer();

        // Unique identification of MBeans
        AWTEvents mbean = AWTEvents.getDefault();
        ObjectName beanName = null;

        try {
            // Uniquely identify the MBeans and register them with the MBeanServer
            beanName = new ObjectName("AWTEventAgent:type=AWTEvents");
            mbs.registerMBean(mbean, beanName);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

Compile the file and launch your targetted application say SwingSet2.jar for e.g as below:

D:\\jdk1.6.0\\demo\\jfc\\SwingSet2>java -Djavax.accessibility.assistive_technologies=AWTEventAgent -Xbootclasspath/p:;. -jar SwingSet2.jar

The above syntax is on Windows and a similar approach on other platforms (Solaris/Linux) using the appropriate path separator could be done.

Note that we use the system property -Djavax.accessibility.assistive_technologies which points to the AWTEventAgent class and it needs to be loaded on startup by specifying the Xbootclasspath to its location.

In jdk 6.0 and onwards, it should be possible to load the above agent in the targetted application using attach on demand feature at run time. I will try to come out with a sample code for it shortly.

Thanks,
Kannan

Sunday Mar 04, 2007

Creating GUI applications using jrunscript

I have always been looking forward to a scripting language for creating and playing with Java GUI applications easily. jrunscript introduced in JDK6.0 is a powerful command line scripting shell. A.Sundarajan has written very useful blogs on jrunscript http://blogs.sun.com/sundararajan/entry/command_line_script_shell_in
In this blog, my attempt is to give an introduction on writing simple GUI applications using JavaScript.
If you have read the above blog, you would know that a group of commands could be grouped into a script file (just like a bat or shell script file)

Create a simple frame of size 400\*400 with a button added to it:
importPackage(javax.swing);
importPackage(java.lang);

frame = new JFrame("JFrame");
frame.setSize(400, 400);

btn = new JButton("click me");
frame.getContentPane().setLayout(new java.awt.FlowLayout());
frame.getContentPane().add(btn);
frame.setVisible(true);
Thread.sleep(2000);


The code above is pretty straightforward and except for the two lines, the rest are what a developer would ideally write in a simple java program. For details on the jrunscript syntax, refer to the above blog as suggested.
Save the above code into a file (say test.js) and run jrunscript test.js

Create listeners (interfaces) containing single method only

One way is to define a simple javascript function and pass it to the actionListener as below:

btn = new JButton("click me");
function action(e)
{
System.out.println("button clicked..." + e.getID());
}
btn.addActionListener(action);

The argument e here maps to java.awt.event.ActionEvent class.

Second way is to define the exact method name as defined in ActionListener interface in java.awt.event package and create a JavaScript object out of it

btn = new JButton("click me");
listener1 = {
actionPerformed: function (e)
{
System.out.println("ActionPerformed: button clicked..." + e.getID());
}
}

alistener = new ActionListener(listener1);
btn.addActionListener(alistener);


Note above that alistener is the ActionListener object created using listener1 javascript object.


Create listeners(interfaces) containing multiple methods:

Consider another simple example where I would want to trap key events (keypressed, keytyped, keyreleased) in an editable field (JTextField for instance). java.awt.event.KeyListener interface has multiple methods declared inside it.

This is how one could implement it

listener2 = {
keyPressed: function(e)
{
System.out.println("key Pressed..." + e.getID());
},
keyReleased: function(e)
{
System.out.println("key Released..." + e.getID());
},
keyTyped: function(e)
{
System.out.println("key Typed..." + e.getID());
}
}

keylistener = new KeyListener(listener2);
tf = new JTextField("Type here");
tf.addKeyListener(keylistener);

Note above that function definitions are separated by commas inside the listener2 javascript object block.


A simple animation using JDialog:

parent = new JFrame();
dlg = new JDialog(parent, "JDialog(Modaless)", false);
label = new JLabel("This is a cool demo using jrunscript tool...");
dlg.getContentPane().add(label);
x=400;
dlg.setLocation(x, 200);
dlg.setVisible(true);
var size = dlg.getWidth();
expand = true; //expand dialog
while (true) {
if (expand && size < 400) {
dlg.setLocation(x, 200);
dlg.setSize(size, 50);
size = size + 6;
x = x - 3;
Thread.sleep(20);
continue;
}
expand= false; //shrink dialog
if (size > 0) {
dlg.setLocation(x, 200);
dlg.setSize(size, 50);
size = size - 6;
x = x + 3;
Thread.sleep(20);
continue;
}
expand = true;
}

The code above when run would expand and shrink a dialog with a time delay of 20ms. The exact degree of smoothness may depend on the system's configuration but the above code should give you an idea of what is being tried out here.


A multitask application combining all the above code along with another JList where items are selected by rotation

Here is the complete runnable code;


importPackage(javax.swing);
importPackage(java.lang);
importPackage(java.awt.event);

frame = new JFrame("JFrame");
frame.setSize(400, 400);

btn = new JButton("click me");
function action(e)
{
System.out.println("button clicked..." + e.getID());
}
listener1 = {
actionPerformed: function (e)
{
System.out.println("ActionPerformed: button clicked..." + e.getID());
}
}

alistener = new ActionListener(listener1);
btn.addActionListener(alistener);

listener2 = {
keyPressed: function(e)
{
System.out.println("key Pressed..." + e.getID());
},
keyReleased: function(e)
{
System.out.println("key Released..." + e.getID());
},
keyTyped: function(e)
{
System.out.println("key Typed..." + e.getID());
}
}


keylistener = new KeyListener(listener2);

tf = new JTextField("Type here");
tf.addKeyListener(keylistener);
frame.getContentPane().setLayout(new java.awt.FlowLayout());
frame.getContentPane().add(tf);
frame.getContentPane().add(btn);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

frame1 = new JFrame("JList...");
strs = java.lang.reflect.Array.newInstance(java.lang.String, 5);
strs[0] = "First";
strs[1] = "Second";
strs[2] = "Third";
strs[3] = "Fourth";
strs[4] = "Fifth";
list = new JList(strs);
frame1.getContentPane().add(list);
frame1.setLocation(500, 0);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setSize(400, 400);
frame1.setVisible(true);

runit = {
run: function() {
index = 0;
while (true) {
if (index > 4) index = 0;
list.setSelectedIndex(index);
index++;
Thread.sleep(200);
}
}
}
t = new Thread(Runnable(runit));
t.start();


parent = new JFrame();
dlg = new JDialog(parent, "JDialog(Modaless)", false);
label = new JLabel("This is a cool demo using jrunscript tool...");
dlg.getContentPane().add(label);
x=400;
dlg.setLocation(x, 200);
dlg.setVisible(true);
var size = dlg.getWidth();
expand = true; //expand dialog
while (true) {
if (expand && size < 400) {
dlg.setLocation(x, 200);
dlg.setSize(size, 50);
size = size + 6;
x = x - 3;
Thread.sleep(20);
continue;
}
expand= false; //shrink dialog
if (size > 0) {
dlg.setLocation(x, 200);
dlg.setSize(size, 50);
size = size - 6;
x = x + 3;
Thread.sleep(20);
continue;
}
expand = true;
}
Thread.sleep(2000);


Hopefully the above code should run fine for everyone :-)

This should perhaps help GUI beginners to get started writing simple GUI programs and gradually continue playing with the powerful APIs offered by java GUI.

Any questions or comments are most welcome

Thanks,
Kannan

Thursday Aug 10, 2006

Windows tricks



Introduction:

I know there are tonnes of articles out there on the web where several tips and tricks on different windows flavors are provided.

I am listing out a few of the tricks/shortcuts that I use more commonly and some that I found out by myself by playing with the keyboards and registry. I mostly work on Win2K and WinXP and hence the tricks below are applicable to NT based systems unless otherwise specified.


1. Autotab feature

Most of the new windows oses(WinXP, Windows Vista..) have the autotabbing feature on the command prompt window. Some people may not know that these are available on Win2K and WinNT also. It's just that they are disabled by default and here is how you enable it.

  • Open regedit.exe

  • Look for the entry HKEY_CURRENT_USER\\Software\\Microsoft\\Command Processor

  • Modify the value of key "Completion Char" to 9

  • Restart command prompt and the autotab key is there for you.


2. Launching programs on startup

  • One common way that users follow is adding the program name in the Programs\\Startup menu.

There are situations where you wouldn't want your program to appear on the startup menu but still be launched on startup. Here is what you do then:

  • Open regedit.exe

  • Look for the entry

  • HKEY_CURRENT_USER\\Software\\Microsoft\\CurrentVersion\\Run

  • Add key-value pairs for each program that you want to launch on startup.

For e.g. notepad "c:\\winnt\\system32\\notepad.exe"

The keyname could be anything of your choice. The value is an absolute path to the application's location.

3. How to bypass windows login screen on startup

  • Open regedit.exe

  • Look for the entry HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon

  • Now add (if they don't exist already) the below keys into this entry.

DefaultUserName <userid>

DefaultPassword <passwd>

DefaultDomainName <domain>

AutoAdminLogon 1 (i.e. Set its value to “1”)


4. Bginfo for keeping system uptodate


A nice tool from sysinternals.com. This is a tool which when installed, attaches itself as a wallpaper to the desktop. The tool displays relevant information about your computer (like hostname, ipaddress, memory size ...). It updates the computer information everytime you boot the system and is always uptodate.

http://www.sysinternals.com/utilities/bginfo.html


5. Shortcuts

This is for systems with windows key which is found in all the keyboards in the present days.

Assuming I represent windows key as "#" just for simplicity, here are the applications I launch easily with the windows key + a character key combination (i.e. both pressed together).


# and e -> opens windows explorer

# and f -> opens search for files and folders window

# and r -> opens run command box

# and u -> opens utility manager

# and d -> minimizes all visible windows on the screen


6. Stopping CDs from Auto Running

Most of the CDs (like video, movies, audio ...) startup automatically as soon as the CD is inserted into the drive on NT based systems. There are times where I do find this irritating. I know I am really picky sometimes.

To prevent this, do this

  • press and hold on shift key when the CD is inserted and until it stops spinning. This will prevent the autorunning of CD.


7. Increasing/Decreasing font size on browsers (IE, Mozilla FireFox, ...)

  • The general way is to use the View->Text Size menu option in either of IE/Mozilla to increase or decrease the text size of the currently viewed page.

  • Easier way (that I use all the time) is hold down ctrl key + scroll mouse wheel upwards or downwards for decreasing/increasing font size respectively.


8. Move window to fullscreen mode

This may not be applicable to all windows applications. For commonly used applications that provide fullscreen feature in their menus, there is another easiery way of entering into full screen mode


  • ctrl + double click on the title bar

  • or just press F11 key


That's it for all I could remember at this point. Will keep updating it as and when I remember any more tricks that I normally use.


Kannan Balasubramanian


Wednesday Aug 09, 2006

Some Basic Desktop configurations

 



 

Objective:

Solaris Sparc:

Graphics card

Resolution

Resolution change

Color Depth

Color Depth change

How to run Java in the same color bit depth as the console:

How to change the default color depth:

Setting up printer

Change the default printer temporarily

Some useful commands on Solaris:

Linux:

Mounting file systems

Determine Run Level

Graphics card

Resolution

Resolution change

Color Depth

Color Depth change

Setting up printer

Useful commands related to printer on Linux

Some useful commands on Linux

Windows:

Graphics card

Resolution

Resolution change

Color Depth

Color Depth change

Setting up printer

Create a snapshot of any image/window

Some useful commands on Windows
 
 


Objective: This document aims at

  • pointing out the different environment setups, flags needed to run 2D testsuites on various platforms
  • getting familiarised with the different commands and setups on different os.
  • troubleshooting the different problems that may arise during test execution.

Solaris Sparc:

The information given here may not be common to all the Sparc Solaris (2.6, 2.7, 8, 9) machines, but a majority of them should work.
 
 

Graphics card:

Some of the commonly used framebuffers and the command for each on Sparc Solaris are as below:
 

 
Framebuffers(Graphics card) Command
ffb (Creator3D ) ffbconfig
afb (Elite3D) afbconfig
ifb (Expert3D) ifbconfig
m64 (PGX8, PGX24) m64config
GFX(PGX 32) GFXconfig

 
 

More details about graphics card:

To get an idea of what framebuffers are available in your machine, type 'ls -l /dev/fbs' and you can guess on the framebuffers by looking at the list available. For e.g. on my machine, the above command gave the following output:
 

  • afb0-> ../../devices/SUNW,afb~1e,0:afb0
  • m640-> ../../devices/pci@1f,0/pci@1,1/SUNW,m64B@2:m640
Now try to map afb\* and m64\* in the above table and you can get an idea of what graphics card your machine has. In this case, I have a Elite3D and PGX graphics card. To get more details on the graphics card, you need to explore the framebuffer's command line options.

Resolution:To get the current resolution and the set of supported resolutions, type <command name> -prconf.

For e.g. if the machine has a 'afb' framebuffer, type 'afbconfig -prconf'.

Resolution change: To change the resolution do the following:

e.g.  m64config -res 1152\*900\*76 now -depth 24 (assuming PGX24 is the framebuffer, I have)

The syntax would be similar for most of the framebuffers.

Color depth: To get the current color depth, type 'xwininfo' at the command prompt. The cursor waits for the user to click the mouse on the window whose color depth he/she needs to know. Click on the window and the tool dumps out a lot of information including the color depth.
 

FYI: /usr/openwin/bin/xdpyinfo could also be used for displaying the color depth of the current window.

Note: On Solaris unlike windows, different windows could be running on different color bit depth.

Color depth change:  This is an interesting feature for Java applications running on Sparc Solaris.

Important: Java always tries to run applications in the best color depth(not resolution) possible on Solaris.

So if my machine supports 8, 16, 24 bit color depths and the console from where the Java app is launched is in 8 bit, the application would still be running on 24 bit color depth. You can verify this by using the xwininfo command (as mentioned above).

How to run Java in the same color bit depth as the console:

set the environment variable FORCEDEFVIS and launch the Java application.

How to change the default color depth:

modify /etc/dt/config/Xservers file by changing the value of 'defdepth' parameter and restart X server.

If the file 'Xservers' doesn't exist, copy the default one from /usr/dt/config/Xservers to /etc/dt/config directory.


Setting up printer:

On the desktop, you would generally find the 'Personal Printers' menu which has normally 3 printer related options

    • Default -> shows the default printer where all printjobs will be redirected to, if printed without selecting any printer from the print dialog.
    • Printer Selector -> invokes a 'Printer Selector tool' dialog displaying a list of all the printers on the network. The user can select any printer from the 'All Printers' list, add it to the 'Selected Printers' and change the default one by clicking on the 'Change Default' button. Click on 'Save Changes' button and restart Xserver to get the changes into effect.
    • Print Manager -> shows the status of each print job on all the connected printers. The user has the option to cancel a print job in the queue using 'Print Manager' tool.
Incase, the above 3 menu options are not found on desktop, the mentioned 3 dialogs could be invoked with the following command:
    • Default -> /usr/dt/bin/dtprintinfo
    • Printer Selector -> /usr/dist/share/cue,v2.1.6/tools/std/printer_selector
    • Print Manager -> /usr/dt/bin/dtprintinfo -all
Change the default printer temporarily:
If the default printer has to be changed temporarily (say just for a particular application(s) ), do:
  1. setenv LPDEST <printer name> (assuming cshell here)
  2. Launch your application
ifconfig -a -> displays the ip address
prtconf -> displays System configuration, Memory size, System Peripherals
isainfo -kv -> displays instruction set architectures (eg 64-bit sparcv9 kernel modules)
xlsfonts -> displays all fonts in the system.
xfontsel -> for selecting a particular font.
Snapshot -> takes snapshots of selected windows.
Imagetool -> invokes image viewer



Linux:

The information given here may not be common to all the different flavors of Linux (RedHat, Suse, Caldera, Mandrake, Turbo...) but a majority of them should work. Commands specific to certain Linux flavors have been specified wherever possible.
  find the runlevel of your machine (usually it's 5 on most Linux machines with X11 running)

  • check if 'amd' has been turned on/off for the runlevel used
  •         For this: type 'chkconfig --list | grep amd'
    The output would be similar to the one below:
                amd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
    Here, amd is turned on for runlevel 5. If not, turn it on by typing
    chkconfig --level 345 amd on
    Step 3 (above) could also be done in another simpler way by using the gui tool 'ntsysv'

    ntsysv displays all the services and the status of each (on/off).
     

    Determine Run Level:

    Runlevel determines the mode on which the machine has been booted and is currently running. To determine the runlevel of your machine, foll the steps below:

      • open /etc/inittab file.
      • Look for the entry 'initdefault:'
      • The format would be like 'id:<number>:initdefault:
      • The value of <number> is the runlevel of your machine.
    NOTE: The no. of runlevels and the description of each could vary on different flavors of Linux.
    An e.g of the runlevels and its mode description on a RedHat Linux 7.1 is as below:

     
     
    Runlevel Mode
    0 Halt
    1 Single user
    2 Multi user (without NFS)
    3 Multi user (with NFS)
    4 unused
    5 X11
    6 reboot

     

    Graphics card:

    To determine the graphics card on Linux (RedHat), follow the steps:

      1. cd /etc/X11
      2. open XF86Config (XF86Config-4 on RedHat 7.0 and higher) and search for 'Section Screen'
      3. The 'Device' subentry contains the video card name.


    Resolution:

    To determine the current resolution on Linux (RedHat), follow the steps:

      1. cd /etc/X11
      2. open XF86Config (XF86Config-4 on RedHat 7.0 and higher) and search for 'Section Screen'
      3. The 'Modes' subentry under 'Display' subsection represents the resolution.


    Color Depth:

    To determine the current resolution on Linux (RedHat), follow the steps:

      1. cd /etc/X11
      2. open XF86Config (XF86Config-4 on RedHat 7.0 and higher) and search for 'Section Screen'
      3. The 'Depth' subentry under 'Display' subsection represents the color depth.
    Color Depth change:
    Follow the steps above and change 'Depth' to the desired value and restart X server.
    Setting up printer:

    There are different tools for setting up printer on different linux versions.

    Some commands that I know of:
     

     
    Linux version Command
    RedHat Linux (any version) printtool
    Turbo Linux turboprintcfg
    Caldera Linux kups(GUI) or cupsd(command line)
    Mandrake Linux /usr/bin/printtool  or  /usr/sbin/printerdrake
    SuSE Linux
    /sbin/yast (for configuring anything not only printer)

    Trick: Generally (but not on all linux machines), you would find the printer command for adding/editing/deleting a printer from the /etc/printcap file.

    e.g. for RH Linux (7.0 & higher)

      1. type 'printtool' at the console.
      2. Click on 'New' icon. It brings up a 'Edit Queue' dialog.
      3. Type any name under 'Name and Aliases'->'Queue Name'
      4. Enter printer server name under 'Queue Type'->'Server'
      5. Enter printer name under 'Queue Type'->'Queue'
      6. Select the appropriate driver under 'Printer Driver' category
      7. Click on 'ok'. This goes back to the first dialog.
      8. Save the changes by selecting 'File'->'Save Changes'.
      9. Restart the lpd with 'File'->'Restart lpd'
      10. Test the printer by selecting any of the option from 'Test' menu.
      11. If the printer works, you are all set to use the printer.
    The tool and the procedure above is similar for RH 6.2. (The menu options are a bit different).
    Note : Users generally forget/(are unaware) of steps (8 and 9). If lpd is not re-started, user cannot print to the newly added printer in the current login session.

    Restart lpd from command line:

    To manually restart lpd from command line, do the foll:

    /etc/init.d/lpd stop and /etc/init.d/lpd start
    or
    lpc reload all
    Useful commands related to printer on Linux:

    lpq gives status of all the printjobs.

    lprm command for remove printjobs (lprm jobid)
    lpc status gives status of the connected printer.
    lpc printcap gives info on the printcap for the default printer.

    /net/sqesvr/deployment2/kannan/tools/linuxver

    Some useful commands on Linux:

    Note: The commands below may not be applicable on all the different flavors of Linux .

    ifconfig -a -> displays the ip address

    cat /proc/cpuinfo -> shows cpu details.
    cat /proc/version -> shows kernel version, gcc version and release version.
    /usr/bin/xproc -> gives all the details of above two and a lot more.
    /usr/bin/xpaint -> similar to pbrush in Windows. Also has SNAPSHOT option.
    /usr/X11R6/bin/xfig -> similar to pbrush in Windows
    /usr/bin/whatis -> describes the command.
    gfontsel -> Font selector (GUI App)

    Windows:

    The best way to know all the hardware details about your PC is by using 'belarc' software.

    Go to http://www.belarc.com and download the 'belarc advisor'. The installer after installation would show all the details about your PC.

    Graphics card:

    On most of the Windows platform, the common way to find out the graphics card is as follows:

    Method 1:

      1. Right click on the desktop.
      2. Click properties and the 'display properties' dialog pops up.
      3. Select the Settings tab.
      4. you should be able to find the graphics card name below the Display label.
    Method 2:
    If the above method doesn't show the card name (I have seen on Windows NT especially), do the following:
      1. Open command prompt
      2. Type 'debug' and press <ENTER> key.
      3. At the '-' prompt, type 'd c000:0'
      4. You would possibly see the graphics card name on the right. If it still doesn't appear, type 'd' once or twice and the name should certainly appear.
    Note: 'debug' command doesn't seem to be available on Windows XP (64-bit)


    Resolution:

    To get the current resolution and all possible resolution follow the steps 1-3 in 'Method 1' of Graphics card section.

    Find the value of the current resolution in the 'Screen Area' label. Click/drag the slider to change the resolution.
     

    Color depth:

    To get the current color depth and all possible color depths follow the steps 1-3 in 'Method 1' of Graphics card section.

    Find the value of the current color depth in the 'Colors' drop down box. Select a different color depth to change its value.

    Setting up printer:

      Select Control Panel->Printers->Add Printer to add a new printer.

      To select a different driver (other than the existing for a connected printer):

      1. Right click on the printer(whose driver needs to be changed) icon.
      2. Select 'properties' option.
      3. Install a new printer driver from 'Advanced'->'New Driver' button.
    Default printer:
    To change the default printer,
      1. select the printer icon (which has to be made the default).
      2. Right click on the icon
      3. Click on 'Set as Default Printer'
      4. The selected printer becomes the default printer.


    Create a snapshot of any image/window:

      1. Select the window you want to take snapshot of.
      2. Press Alt-PrintScreen key combination on the keyboard. The image gets copied on to the clipboard.
      3. Open any image viewer (like paintbrush or PaintShopPro) and do a paste(Ctrl-v). The image could then be saved in any format supported the viewer.


    Some useful commands on Windows:

    ipconfig /all -> displays the ip address on command line.

    winipcfg -> (GUI tool) for displaying ip address in win98, me and 2000
    msconfig -> system configuration utility.
    Hwinfo /ui -> hardware utility for Windows (may not work on all Windows platform).


    Kannan Balasubramanian
    About

    kannan

    Search

    Categories
    Archives
    « April 2014
    SunMonTueWedThuFriSat
      
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
       
           
    Today