Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Oracle.

http://blogs.sun.com/arungupta/date/20091203 Thursday December 03, 2009

TOTD #114: How to enable Java Console in Mac OS X, Windows, ... ?

Debugging an applet running with Java plug-in or JNLP application running with Java Web Start in the browser requires the "Java Console" so that debugging messages printed using System.out and System.err can be seen. In Windows, there is a "Show Java Console" menu item in Firefox but clicking it still does not show the console. And this happens because the console window is disabled by default.

However the setting can be easily altered as explained below.

On Mac OS, open "Applications" -> "Utilities" -> "Java Preferences"
On Windows, open "Control Panel" -> "Java"
On any platform, type "javaws -viewer"

Click on the "Advanced" tab to see a window similar to the following on Mac OS X:

And the following on Windows:

Change the "Java Console" setting from "Hide console" to "Show console". Launching your JNLP from the browser next time now will also open the "Java Console" as shown below:

and debugging messages will be nicely printed in the console. Read more about the options displayed in the console here.

Technorati: osxtips windows java console jnlp debugging totd

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20091019 Monday October 19, 2009

MacBook Pro Cycle Count – Too High ?

MacBook Pro Cycle Count means the number of times a battery's entire power is used up. It's formally defined as:

A charge cycle means using all of the battery’s power, but that doesn’t necessarily mean a single charge. For instance, you could use your notebook for an hour or more one day, using half its power, and then recharge it fully. If you did the same thing the next day, it would count as one charge cycle, not two, so you may take several days to complete a cycle.

It can be easily determined by clicking on "Apple", "About This Mac", "More Info...", "Hardware", "Power", "Health Information:". MacBook Pro with a replaceable battery retains 80% of its original capacity after 300 cycles as mentioned here. But in all practical cases, I've heard users replacing the batteries closer to 300 counts. This number goes upto 750 for MacBook Air and 1000 for newer MacBook Pro so there is relief already.

My MBP cycle count hit 283 on Friday and the scary part was "Full charge capacity" was down to 258 mAh. In usage terms, a fully charged battery was getting drained out in 10 minutes :(

A new battery was rushed, installed and the new count is certainly the expected number:

Here are some more relevant docs:

Technorati: osxtips battery cyclecount

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20090928 Monday September 28, 2009

TOTD #106: How to install Oracle Database 10g on Mac OS X (Intel) ?

This Tip Of The Day (TOTD) will explain how to install Oracle Database 10g on Mac OS X.

The official documentation is available here and is very well suited for folks with lots of time and patience. But all I wanted was to install Oracle database server up & running on my localhost so that I can start experimenting with it. All my previous entries have used either JavaDB or MySQL so far, but it's about time ;-)

I started preparing a brief tutorial after following the lengthy documentation but then found this excellent blog entry. And realized the content is looking exactly similar :-) Anyway, below are the instructions I followed and additionally also provide a snapshot of the installer windows.

For the brave of heart, complete installation guide is available in HTML and PDF. Read on for an abbreviated, and yet working version, of the instructions.

  1. Download Oracle database 10g R2 (10.2.0.4.0) from here and unzip.
  2. Check hardware/software requirements. (10.5.4+ required)
  3. Create required groups/users (complete details):
    1. Create Oracle inventory group as:

      # dscl . -create /groups/oinstall
      # dscl . -append /groups/oinstall gid 100
      # dscl . -append /groups/oinstall passwd "*"
      
    2. Create Oracle software owner as:
      # dscl . -create /users/oracle
      # dscl . -append /users/oracle uid uid_number
      # dscl . -append /users/oracle gid oinstall_gid
      # dscl . -append /users/oracle shell /bin/bash
      # dscl . -append /users/oracle home /Users/oracle
      # dscl . -append /users/oracle realname "Oracle software owner"
      
    3. Create the home directory for Oracle user as:
      # mkdir /Users/oracle
      # chown oracle:oinstall /Users/oracle
      
    4. Set the password for Oracle user:
      # passwd oracle
      
  4. Configure kernel parameters (complete details) by editing "/etc/sysctl.conf" and adding the contents:
    kern.sysv.semmsl=87381
    kern.sysv.semmns=87381
    kern.sysv.semmni=87381
    kern.sysv.semmnu=87381
    kern.sysv.semume=10
    kernel.shmall=2097152
    kernel.sys.shmmax=2147483648
    kernel.sys.shmmni=4096
    kern.maxfiles=65536
    kern.maxfilesperproc=65536
    net.inet.ip.portrange.first=1024
    net.inet.ip.portrange.last=65000
    kern.corefile=core
    kern.maxproc=2068
    kern.maxprocperuid=2068
    
    and reboot the machine for these parameters to take effect.
  5. Configure Oracle user's environment (complete details). In the "oracle" user's home directory, create ".bash_profile" and add the following lines:
    export DISPLAY=:0.0
    export ORACLE_BASE=$HOME
    export ORACLE_SID=orcl
    umask 022
    ulimit -Hn 65536
    ulimit -Sn 65536
    
  6. The "Basic Installation" of "Standard Edition" in an "Interactive" mode can be performed using the "Oracle Universal Installer". This installer is invoked using the script "db/Disk01/runInstaller" (complete details). The screen snapshots are shown below:

















    Choose "oracle" as the database password for simplicity.





    and finally click on "Install" to begin the installation.









    Click on "Password Management..." to unlock the sample database user ...





    The output of these scripts look like:
    ~ > sudo /Users/oracle/oraInventory/orainstRoot.sh
    Changing permissions of /Users/oracle/oraInventory to 770.
    Changing groupname of /Users/oracle/oraInventory to oinstall.
    The execution of the script is complete

    and
    ~ > sudo /Users/oracle/product/10.2.0/db_1/root.sh
    Running Oracle 10g root.sh script ...
    
    The following environment variables are set as:
         ORACLE_OWNER= oracle
         ORACLE_HOME= /Users/oracle/oracle/product/10.2.0/db_1
    Enter the full pathname of the local bin directory: [/usr/local/bin]:
        Copying dbhome /usr/local/bin ...
        Copying oraenv to /usr/local/bin ...
        Copying coraenv to /usr/local/bin ...
    Creating /etc/oratab file...
    Entries will be added to the /etc/oratab file as needed by
    Database Configuration Assistant when a database is created
    Finished running generic part of root.sh script.
    Now product-specific root actions will be performed.




    Click on "Installed Products..." to see the list of Oracle products installed.

  7. There are some more steps before you can start the Oracle listener process.
    1. Edit ".bash_profile" of "oracle" user and add the following settings:
      export ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
      export PATH=$PATH:$ORACLE_HOME/bin
      export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
      Not setting DYLD_LIBRARY_PATH gives the following error:
      ~ oracle$ lsnrctl start
      dyld: Library not loaded: /b/227/network/lib/libnnz10.dylib
        Referenced from: /Users/oracle/oracle/product/10.2.0/db_1/bin/lsnrctl
        Reason: image not found
      Trace/BPT trap
      This was not obvious but Googling helped. Make sure to relogin for these changes to take effect.
    2. If your Mac is using DHCP (most likely) then you may see the error shown below:
      ~ oracle$ lsnrctl start
      
      LSNRCTL for MacOS X Server: Version 10.2.0.4.0 - Production on 28-SEP-2009 14:48:49
      
      Copyright (c) 1991, 2007, Oracle.  All rights reserved.
      
      Starting /Users/oracle/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
      
      TNSLSNR for MacOS X Server: Version 10.2.0.4.0 - Production
      System parameter file is /Users/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
      Log messages written to /Users/oracle/oracle/product/10.2.0/db_1/network/log/listener.log
      Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
      Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dhcp-usca14-133-197.SFBay.Sun.COM)(PORT=1521)))
      TNS-12545: Connect failed because target host or object does not exist
       TNS-12560: TNS:protocol adapter error
        TNS-00515: Connect failed because target host or object does not exist
         MacOS X Server Error: 49: Can't assign requested address
      
      Listener failed to start. See the error message(s) above...


      This error occurs because your MacBook may be running on a different IP address if rebooted after the installation and before starting the server. Fortunately, the error message is very intuitive and it's easy to fix the error by editing "$ORACLE_HOME/network/admin/listener.ora" as shown below:
      # listener.ora Network Configuration File: /Users/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
      # Generated by Oracle configuration tools.
      
      SID_LIST_LISTENER =
        (SID_LIST =
          (SID_DESC =
            (SID_NAME = PLSExtProc)
            (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
            (PROGRAM = extproc)
          )
          (SID_DESC =
            (SID_NAME = orcl)
            (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
          )
        )
      
      LISTENER =
        (DESCRIPTION_LIST =
          (DESCRIPTION =
            (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
            (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
          )
        )
      

      The changes are highlighted in the bold. Basically, add a new SID referring to "orcl". And for DHCP users the value of HOST key needs to be changed from dynamically assigned IP address to "localhost". Strangely, the Installing on DHCP Computers section of the installation guide says nothing about it :(
    3. Additionally, for DHCP users, you need to change "$ORACLE_HOME/network/admin/tnsnames.ora" as:
      # tnsnames.ora Network Configuration File: /Users/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
      # Generated by Oracle configuration tools.
      
      ORCL =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
          (CONNECT_DATA =
            (SERVER = DEDICATED)
            (SERVICE_NAME = orcl)
          )
        )
      The changes are highlighted in bold. And here as well change the value of HOST key to "localhost".
  8. And finally, start the database using SQL*Plus as:
    ~ oracle$ sqlplus "/ as sysdba"
    
    SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 28 17:44:40 2009
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to an idle instance.
    
    SQL> startup nomount
    ORACLE instance started.
    
    Total System Global Area  612368384 bytes
    Fixed Size                  2085872 bytes
    Variable Size             167775248 bytes
    Database Buffers          436207616 bytes
    Redo Buffers                6299648 bytes
    SQL> alter database mount;
    
    Database altered.
    SQL> alter database open;
    Database altered.
    
    SQL> ALTER USER HR IDENTIFIED BY hr ACCOUNT UNLOCK;
    User altered.
    
    SQL> exit
    Disconnected from Oracle Database 10g Release 10.2.0.4.0 - Production
    The last step of unlocking the account should not be required because we explicitly unlocked the account during installation but that apparently didn't work. And I hit ORA-01033, ORA-01034, ORA-12514, ORA-12541, ORA-12547, and ORA-27101 trying different combinations to get the app working.

    Anyway now re-connect to the HR sample database as:
    
    ~ oracle$ sqlplus hr/hr@orcl
    
    SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 28 17:46:19 2009
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    
    Connected to:
    Oracle Database 10g Release 10.2.0.4.0 - Production
    
    SQL> select table_name from user_tables;
    TABLE_NAME
    ------------------------------
    REGIONS
    LOCATIONS
    DEPARTMENTS
    JOBS
    COUNTRIES
    EMPLOYEES
    JOB_HISTORY
    
    7 rows selected.
    
    SQL> desc regions;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     REGION_ID                                 NOT NULL NUMBER
     REGION_NAME                                        VARCHAR2(25)
    
    SQL> select * from regions;
     REGION_ID REGION_NAME
    ---------- -------------------------
             1 Europe
             2 Americas
             3 Asia
             4 Middle East and Africa
    

    Note: If the database is not shutdown properly then it can be forced to do so using the command "shutdown abort" using SQL*Plus.

A complete archive of all the tips is available here.


Technorati: totd oracle database mac osxtips leopard installation

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080430 Wednesday April 30, 2008

OSX #8: Java SE 6 U5 on Mac OS X Leopard


Yesterday, Apple released Java SE version 1.6.0_05 for 64-bit Intel-based Mac OS X 10.5.2 or later. Download it here!

It's restricted to 64-bit machines and Charles is unhappy about it. Hopefully, they'll release a 32-bit version as well.

Type "sw_vers" in a terminal to check the Mac OS X version as shown below:

~ >sw_vers
ProductName:    Mac OS X
ProductVersion: 10.5.2
BuildVersion:   9C31
Alternatively, "About This Mac" in the Apple menu shows you the version as well as shown below:



Anyway, after verifying the system requirements, download 57MB bundle and install it following the standard instructions.


And now successfully installed:



It gets installed in "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0" and shows the version number as:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin >./java -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13-120)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_05-b13-52, mixed mode)

The default Java version can be changed by using "Java Preferences" as shown below:
/Applications/Utilities/Java/Java Preferences.app/Contents/MacOS >./"Java Preferences"
The following window shows up:



Pick the version of your choice and that should get you going!

These are the days before JavaOne and all my demos on this machine have been tested using the default J2SE 5. But I'll play with the new release after JavaOne anyway :)

Do you know sign up for GlassFish Day is FREE and gives you access to JavaOne pavilion as well ? Do it now!

A complete archive of all Mac OS X tips on this blog are available here.

Technorati: osxtips mac leopard javase6 javase jdk

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080115 Tuesday January 15, 2008

OSX #7: Upgrading Mac OS X from Tiger to Leopard

Did you buy a new or refurbished Macintosh computer on or after Oct 1, 2007 ?
And it does not have Mac OS v10.5 Leopard ?
And would like to upgrade ?
And save money ?

See if you qualify (new or refurbished). If you do, then you can upgrade using a Single-User Upgrade Kit at the cost of $9.95. This offer expires Jan 26, 2008.

Read more details in Mac OS X Leopard Up-to-Date Program.

I ordered mine last week, got the delivery in 3 days and upgraded this morning. Really simple! Now I'm using Mac OS v10.5 Leopad on my MacBook Pro :)

A complete archive of all Mac OS X tips on this blog are available here.

Technorati: mac osxtips tiger leopard

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20080104 Friday January 04, 2008

OSX #6: Organizing your Dock & Dashboard

Dock is the Windows Start Bar equivalent in MacOS. However if a program is installed on your MacBook, unlike Windows, you'll need to explicitly add it to the Dock.
To add an icon to Dock: Just click on the Finder icon in Dock, Finder Icon, locate the installed program and drag/drop the icon to Dock. This can be done from the Desktop as well.
To remove an icon from Dock: just drag it away from the Dock onto the desktop; the icon will disappear in a poof of smoke Icon deleted from Dock

Mac DashboardDashboard is Windows Sidebar equivalent in MacOS - it is used for hosting widgets and activated by the default keyboard shortcut of F12.  

To add widgets to Dashboard: Some common widgets are included with the OS itself and can be enabled by clicking on the + button in left-bottom corner of the screen when Dashboard is visible. More widgets can be downloaded from here or by clicking on +, "Manage Widgets..." and "More Widgets...". MacBook Dock - Manage Widgets

To remove widgets from Dashboard: Deleting a widget requires you to hold the Option key over a widget which enables a X in the left-top corner of the widget. Just click on the X and the widget will disappear.

A complete archive of all Mac OS X tips on this blog are available here.

Technorati: mac osxtips dock dashboard widgets

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071226 Wednesday December 26, 2007

OSX #5: Alt-Tabbing in Mac (Switching between windows on Mac)

Alt-Tabbing in Windows shows currently open windows and allows to select one of them which then becomes the active window. If there are 3 Firefox windows, then it'll show 3 icons. A slightly different behavior is available in Mac where it shows one icon for all the open windows of an application and then provide a different keyboard shortcut to switch between all the windows of that application.

Switch between different applications: Command+Tab (for example if you have Firefox, Thunderbird and other applications). Shift+Command+Tab moves in the reverse direction.
Switch between different windows of the same application: Command+~ (for example if you have multiple windows of Firefox). Shift+Command+~ moves in the reverse direction.

However if the application is minimized then it is not activated (which is bizarre)!

If you are holding the command key and hit Q then that particular application will quit, if you hit H then that application will hide (go behind all the applications?).

A complete archive of all Mac OS X tips are available here.

Technorati: mac osxtips

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071224 Monday December 24, 2007

OSX #4: How to forcibly kill an application on Mac ?

The Task Manager in Microsoft Windows is multipurpose. However the most common use, IMHO, is to kill a misbehaving application or that is "Not Responding".  This is called as "Force Quit" on Mac and can be achieved by calling Command+Option+Esc which brings up a window like:

Force Quit window

Then you select the application that you would like to shutdown and click on "Force Quit" button. As in Windows, you will loose any unsaved data.

A complete archive of all Mac OS X tips are available here.

Technorati: mac osxtips

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071223 Sunday December 23, 2007

OSX #3: How to eject CD/DVD in Mac ?

  1. If there is a CD in your drive, then there will be an icon on your desktop as shown below:

    Mac CD Icon
  2. Go to "File" menu in the menu bar and click "Eject <DISK LABEL>" as shown below:

    Mac CD Eject

    Alternatively you can press Command+E in that window.

A complete archive of all Mac OS X tips are available here.

Technorati: mac osxtips

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071221 Friday December 21, 2007

OSX #2: How to capture screen on Mac ?

  1. Capture a portion of the screen: Press Command+Shift+4 and the pointer turns into a bull's eye. Select area of the screen that you wish to capture. That part of the screen is captured and saved as PNG file on your Desktop "Picture 1.png" as shown below:

    Screenshot Capture Image
  2. Capture the entire screen: Command+Shift+3 captures the entire screen.
  3. Capture a highlighted window: Command+Shift+4, Space, (cursor turns into a camera), Click in the highlighted window.
Now Control+Command+Shift+ 3 or 4 will copy the captured image in Clipboard memory instead of creating a file on the Desktop. All of these keyboard shortcuts can be easly customized by going to Preferences -> Keyboard & Mouse -> Keyboard Shortcuts as shown below:

screen capture default keyboard shortcuts

A complete archive of all Mac OS X tips on this blog are available here.

Technorati: mac osxtips

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

http://blogs.sun.com/arungupta/date/20071220 Thursday December 20, 2007

OSX #1: Getting Started with a Mac for a Windows User

MacBook Image I got a new Apple MacBook Pro (Intel Core 2 Duo, 2GB RAM, 160 GB HDD and other good stuff) and excited about that! However I've been a Windows user all along and this is my first interaction with a Mac.

So here are some basic tips/tools to get you started if you are in the same situation:

  • Start with Mac101 - This will get you familiar with Mac, basic terminology, some keyboard hints and other misc stuff.
  • Keyboard mappings between a Windows and Mac keyboard are very different. It would help to print out the mappings and keep them handy. It can take more than a day to get used to the new mappings. Some specific ones are:
    • "Right-click"ing is not intuitive - Enable Two-Finger Click on the Trackpad
    • No Forward Delete key, Mac equivalent is Fn + Delete
    • No dedicated Home, Page Up or Page Down keys, Instead use Fn + Cursor keys
  • Install the following tools
Also read 10 tips for Mac users switching from Windows and a more comprehensive list at Switch to The Mac.

The box came installed with Tiger (Mac OSX 10.4) as opposed to Leopard (Mac OS X 10.5). Leopard Updates are available for $9.95 until Jan 4th, 2007.

Some other striking difference in the terms of UI are:

  • The menus, instead of stacked to each window, are always available at the top.
  • "Windows Control Panel" is available as "System Preferences" on Dock (the toolbar which is, by default, at the bottom of the screen).
  • Minimize/Maximize/Close buttons are to the left instead of to the right.
  • Maximize button only maximizes to the required extent instead of occupying the entire desktop.
  • Important keyboard shortcuts
    • F9 - Shows all open windows
    • F10 - Shows all open windows for the current application (every thing else is greyed out)
    • F11 - Hides all windows and shows the Desktop
    • F12 - Show Dashboard

Here are some other tasks that I tried:

  • iMovie is really cool, I could easily create a movie (with in-built camera) and upload a video directly to youtube. Really good intuitive interface.
  • Create clean HTML pages (like this blog): TextEdit (the default editor) adds redundant markers and viewing HTML source code is not intuitive/easy. So does NeoOffice. Microsoft Front Page is really good at that and I've thoroughly enjoyed editing my blogs using it. So I'm looking for something comparable on Mac. I found this HTML editor shootout  but most of the editors seem to require some manual addition of HTML tags. Googling further, I found KompoZer (based on Nvu) and liking it so far. Part of the reason is that the look-and-feel is quite like FrontPage ;-)

These tips will at least get you started where you can check Email, IM and Web, view your documents, import key settings from Firefox/Thunderbird and unleash the potential of GlassFish and NetBeans. Lots of other tips are available here, here and here. I'll post more as I learn them. Feel free to post your favorite tool/tip/guidance here.

A complete archive will be available here.

Technorati: windows mac apple tools osxtips

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.