Welcome to my blog, hope you enjoy reading
RSS

Saturday 8 November 2014

APACHE TOMCAT VERTIONS NOT SHOWING IN ECLIPSE SERVER RUNTIME ENVIRONMENTS (KEPLER/LUNA INSTRUCTIONS)

Following are the steps to install Apache Tomcat and add it into Eclipse Kepler or Luna:


  1. In Eclipse Kepler, go to Help, select ‘Install New Software
  2. Choose “Kepler- http://download.eclipse.org/releases/kepler” site or add it in if it’s missing. If you’re using Luna, choose “Luna – http://download.eclipse.org/releases/luna” site or add it in if it’s missing
  3. Expand “Web, XML, and Java EE Development” section
  4. Check JST Server Adapters and JST Server Adapters Extensions
  5. Once installed, in Eclipse, go to Window / Preferences / Server / Runtime Environments
  6. Press Add button, select Apache / Apache Tomcat v7.0 or Apache Tomcat v8.∞
  7. Press Next, select location on the drive (i.e. c:\apachetomcat) for Tomcat installation directory. Make sure that the directory exist.
  8. Then press ‘Download and Install’ button, accept terms and point to your installation directory (i.e. c:\apachetomcat) and press OK button
  9. Apache TomCat v7.0 will install (you’ll see a progress in the status bar
  10. Press Finish.
  11. Apache Tomcat v7.0 or Tomcat v8.0 (depending on your selection)  will show in the list under Server Runtime Environments now.
Share

Saturday 1 November 2014

How to Install Oracle Java 8 In Ubuntu

Step 1: Install Java 8 (JDK 8)


Add the webupd8team java PPA repository in our system and install Oracle java8 using following set of commands.

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer


Step 2: Verify JAVA Version


After successfully installing oracle java using above step verify installed version using following command.

$ java -version

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Step 3: Setup JAVA Environment


Webupd8team is providing a package to set environment variables, Install this package using following command.

$ sudo apt-get install oracle-java8-set-default
Share

How To Install Java on Ubuntu

Installing default JRE/JDK

This is the recommended and easiest option. This will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK 7.

Installing Java with apt-get is easy. First, update the package index:
sudo apt-get update

Then, check if Java is not already installed:
java -version

If it returns "The program java can be found in the following packages", Java hasn't been installed yet, so execute the following command:
sudo apt-get install default-jre

This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:
sudo apt-get install default-jdk

That is everything that is needed to install Java.
All other steps are optional and must only be executed when needed.

Installing OpenJDK 7 (optional)

To install OpenJDK 7, execute the following command:
sudo apt-get install openjdk-7-jre

This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), execute the following command:
sudo apt-get install openjdk-7-jdk

Installing Oracle JDK (optional)
The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.

You can still install it using apt-get. To install any version, first execute the following commands:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Then, depending on the version you want to install, execute one of the following commands:

Oracle JDK 6
This is an old version but still in use.
sudo apt-get install oracle-java6-installer

Oracle JDK 7
This is the latest stable version.
sudo apt-get install oracle-java7-installer

Oracle JDK 8
This is a developer preview, the general release is scheduled for March 2014. This external article about Java 8 may help you to understand what it's all about.
sudo apt-get install oracle-java8-installer

Managing Java (optional)

When there are multiple Java installations on your Droplet, the Java version to use as default can be chosen. To do this, execute the following command:
sudo update-alternatives --config java

It will usually return something like this if you have 2 installations (if you have more, it will of course return more):

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:
You can now choose the number to use as default. This can also be done for the Java compiler (javac):
sudo update-alternatives --config javac

It is the same selection screen as the previous command and should be used in the same way. This command can be executed for all other commands which have different installations. In Java, this includes but is not limited to: keytool, javadoc and jarsigner.

Setting the "JAVA_HOME" environment variable
To set the JAVA_HOME environment variable, which is needed for some programs, first find out the path of your Java installation:
sudo update-alternatives --config java

It returns something like:

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:
The path of the installation is for each:

/usr/lib/jvm/java-7-oracle

/usr/lib/jvm/java-6-openjdk-amd64

/usr/lib/jvm/java-7-oracle

Copy the path from your preferred installation and then edit the file /etc/environment:

sudo nano /etc/environment
In this file, add the following line (replacing YOUR_PATH by the just copied path):

JAVA_HOME="YOUR_PATH"
That should be enough to set the environment variable. Now reload this file:

source /etc/environment
Test it by executing:

echo $JAVA_HOME
If it returns the just set path, the environment variable has been set successfully. If it doesn't, please make sure you followed all steps correctly.
Share

Tuesday 9 September 2014

Switching between installed Java versions in ubuntu


Switching between installed Java versions can be accomplished using the update alternatives command.

  •     To get a list of your installed Java platforms, run the following command from the terminal:

    sudo update-alternatives --config java
 
  This will give you a list output similar to this:
    There are 2 choices for the alternative java (providing /usr/bin/java).
       Selection    Path                                           Priority   Status
      ------------------------------------------------------------
      0            /usr/lib/jvm/java-6-oracle/jre/bin/java         1070      auto mode
      1            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      manual mode
    * 2            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1069      manual mode
    Press enter to keep the current choice[*], or type selection number:

In this case, the Open JDK 6 version is running. To switch to the Open JDK version 7, you would select option 1 at the prompt and press the Enter key.

You will now be running the OpenJDK 7 version. No other changes will be needed to switch your Java versions.
Share

Saturday 30 August 2014

Temporarily disable Eclipse plugins in load-on-startup

Temporarily disable Eclipse plugins in load-on-startup

Eclipse :Windows-->Preferences-->General-->Startup and Shutdown

De-select unwanted plugins.
Select Apply-->Ok.

Share

Thursday 3 July 2014

Running GWT's Super Dev Mode

Super dev mode is one of the feature given in GWT after 2.5 version.

Share

Thursday 19 June 2014

How do upgrade GWT in Eclipse

How do upgrade GWT in Eclipse

  • Download the GWT SDK(s) you need from https://developers.google.com/web-toolkit/versions
  • Extract it anywhere you like
  • In Eclipse Preferences > Google > Web Toolkit, use the "Add..." button and navigate to the GWT SDK directory
  • Then, in each Eclipse project's properties page (Project > Properties > Google > Web Toolkit), you can choose one of your installed SDKs.  
source
Share

Saturday 14 June 2014

Eclipse (ADT) crash Failed to write core dump. Core dumps have been disabled

I found my problem here: how to fix “Failed to write core dump. Core dumps have been disabled” error while running java and here: Eclipse crashing on startup and here: Eclipse continue crash
Share

Tuesday 20 May 2014

replace() vs replaceAll()

Both replace() and replaceAll() replaces all the occurrence found. However, there is difference in the type of arguments they accept.

Share

Thursday 15 May 2014

What is the size of ” null ” Operator in Java ?

When you write

String st1 = null;
You create a reference “str1″ to an object that still does not exist in the heap, but when you type :

Share

Wednesday 30 April 2014

COALESCE FUNCTION IN PLSQL

The Oracle/PLSQL COALESCE function returns the first non-null expression in the list. If all expressions evaluate to null, then the COALESCE function will return null.
Syntax

The syntax for the Oracle/PLSQL COALESCE function is:

coalesce( expr1, expr2, ... expr_n )


Example

The COALESCE function can be used in Oracle/PLSQL.

You could use the coalesce function in a SQL statement as follows:

SELECT COALESCE( address1, address2, address3 ) result
FROM suppliers;

The above COALESCE function is equivalent to the following IF-THEN-ELSE statement:

IF address1 is not null THEN
   result := address1;

ELSIF address2 is not null THEN
   result := address2;

ELSIF address3 is not null THEN
   result := address3;

ELSE
   result := null;

END IF;

The COALESCE function will compare each value, one by one.
Share

Friday 7 March 2014

Handling multiple updates in Mysql

Handling multiple updates in Mysql 

UPDATE yourtable
    SET updatefield = CASE id
        WHEN 1 THEN 'new value'
        WHEN 2 THEN 'new value'
        WHEN 3 THEN 'new value'
    END
WHERE id IN (1,2,3)
Share

Tuesday 4 March 2014

CPU usage in ubuntu

CPU usage in ubuntu 

You first should figure out what process is eating away your CPU.
  •     open a terminal with ctrl+alt+t
  •     execute the command top
  •     note the process using the most cpu
If the process isn't a system process, kill it with sudo pkill [processname] with [processname] the name of the process you want to kill. If it is a system process, don't kill it, but try to google the name and figure out what functionality it has in Ubuntu. Then you can proceed to turn it of (in e.g. you system settings).
Share

Monday 24 February 2014

Project facet Java version 1.7 is not supported

Project facet Java version 1.7 is not supported 

When i update my java I found the issue "Project facet Java version 1.7 is not supported" To resolve this issue follow the steps.
  1. Go to Ecllipse , right click on your project folder
  2. select the properties
  3. now select Project Facets ,here you will see java, click on the version and change the higher version to lower or as per your requirement .

Share

Sunday 23 February 2014

How to Use RichTextToolbar in GWT

How to Use RichTextToolbar in GWT 

If you’ve ever tried to use the RichTextToolbar that is showcased in the Gwt Showcase, you will quickly find out that it’s not actually built into GWT.  Many GWT developers have experienced this WTFery, as their hopes to conveniently import RichTextToolbar have been dashed.  It is supposedly so that developers are not locked into using that toolbar, but of course, a good default is better than no default…

As you can see here, multiple bugs have been filed about this exact issue since 2008, to no avail!  Drats, I guess it is one of those things that has low priority because there’s a work-around, but it does affect a good number of developers, which should count for something.

Anyway, to use it in your code:

  •     Navigate to <path>/gwt-2.0.3/samples/Showcase/src/com/google/gwt/sample/showcase/client/content/text on your computer, and you should see a bunch of icons, RichTextToolbar.java and RichTextToolbar$Strings.properties.
  •     Copy RichTextToolbar.java and RichTextToolbar$Strings.properties and paste them into your source code folder and modify the package names accordingly.
  •     Copy all the icons and paste them somewhere (I created a folder  <project>/client/icon)
  •     In RichTextToolbar.java, above each “Image Resource…”, you will need to indicate the source of the image.  For example,

    @Source(“../icons/bold.gif”)

    ImageResource bold();

    if the directory you copied RichTextToolbar.java is under client.

That’s it, a little annoying, but hopefully it will find its way into GWT itself soon, though don’t hold your breath.

Also, you can easily play around with the Toolbar– I removed the bottom row of ListBoxes that give you lots of control over background and foreground colors, font and font sizes (I don’t want my users to have that much control over how my website looks!), and it ends up looking like this:

Hope that helps, and that it will save a few people some time!

Related posts:


Share

Allow only Numeric in HTML inputbox

Allow only Numeric in HTML inputbox Following code is used to allow only numeric (0-9).

<script language="Javascript">
      function isNumber(evt) {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
 
         return true;
      }
</script>
 
<input onkeypress="return isNumber(event)" type="text">


Another Way

Following code is used to allow only numeric (0-9).
   
<script language="Javascript">
     function validate(evt) {
      var theEvent = evt || window.event;
      var key = theEvent.keyCode || theEvent.which;
      key = String.fromCharCode( key );
      var regex = /[0-9]|\./;
      if( !regex.test(key) ) {
        theEvent.returnValue = false;
        if(theEvent.preventDefault) theEvent.preventDefault();
      }
    }
</script>
 
<input onkeypress="return isNumber(event)" type="text">

Share

STRUTS : java.lang.IllegalAccessException

STRUTS : java.lang.IllegalAccessException

STRUTS : java.lang.IllegalAccessException: Class org.apache.struts.util.RequestUtils can not access a member of class view.myAction with modifiers "

Share

Thursday 13 February 2014

Wampserver : #1045 – Access denied for user ‘root’@'localhost’ (using password: NO)

Here is a simple way to solve #1045 – Access denied for user ‘root’@'localhost’ (using password: NO) error…

Just follow the steps:

Note: [WAMP_PATH] is the path to the wampserver directory in your computer so it can be anything. Default (C:\wamp).

   1. First, go to [WAMP_PATH] > apps > phpmyadmin3.5.1.
   2. Then find and open config.inc.php in your text editor
   3. Now find $cfg['Servers'][$i]['password'] = ”; and change it with $cfg['Servers'][$i]['password'] = ‘admin’; (You can put anything in place of admin as your password, this is only a test password).
   4. Now find $cfg['Servers'][$i]['AllowNoPassword'] = true; and replace it by $cfg['Servers'][$i]['AllowNoPassword'] = false;.
   5. Thats it now save that file.
   6. Now restart the wampserver. To do this left-click the wamp icon in the windows taskbar (Notification one), a box will pop up then just click on Restart all Services.

Yeah! You have successfully resolved the error. If you face any error make sure to comment or email me.


For login page getting
1.find $cfg['Servers'][$i]['auth_type']  and change the value like
$cfg['Servers'][$i]['auth_type'] = 'cookie';
2.save the page.
3.restart the server.
for info see the link video.

Share

Saturday 1 February 2014

How to swap keys and values in a Map

How to swap keys and values in a Map 



package com.javanotes2all.java.collectionfw;

import java.util.HashMap;
import java.util.Map;

public class SwapKeysAndValuesinMap {

 public static void main(String[] args) {
  HashMap map=new HashMap();
  map.put("1", "a");
  map.put("2", "b");
  map.put("3", "c");
  map.put("4", "d");
  map.put("5", "e");
  map.put("6", "f");
  map.put("7", "g");
  System.out.println("before swap"+map);
  map=reverse(map);
  System.out.println("after swap"+map);
 }
 public static  HashMap reverse(Map map) {
     HashMap rev = new HashMap();
     for(Map.Entry entry : map.entrySet())
         rev.put(entry.getValue(), entry.getKey());
     return rev;
 }
}


Share

Thursday 23 January 2014

GWT KeyPressHandler getCharCode issues

GWT KeyPressHandler getCharCode issues 

  • event.getNativeEvent().getKeyCode()
  • KeyCodes.KEY_ENTER=13
This code returns the '10' in chrome so the following code is not working.
  • if(event.getNativeEvent().getKeyCode()==KeyCodes.KEY_ENTER)
This code returns the '13' in firefox so the following code is working. 

so like the code like following for both chrome and firefox
  • if(event.getNativeEvent().getKeyCode()==13)
  • {
  • //Do something
  • }else if(event.getNativeEvent().getKeyCode()==10)
  • {
  • //Do something
  • }



Share

Sunday 12 January 2014

How to execute Runnable file in Ubuntu 13.10

How to execute Runnable file in Ubuntu 13.10 

Open the file manager, go to the Files menu and select Preferences to open the "Preferences" dialog.

In the Behaviour tab activate the option Run executable text files when they are opened in the Exexcutable Text Files section:


 
Share

Saturday 4 January 2014

One table comma(,) separated values to get another table data in mysql

One table comma(,) separated values to get another table data in mysql

problem:

I have two tables:

Posts Table

PostID | Gallery
  1    | 4,7,8,12,13
  2    | 1,2,3,4
  3    | 5,8,9
  4    | 3,6,11,14
Share

How to start wamp automatically upon Windows start-up

How to start wamp automatically upon Windows start-up 

1) Log in as an administrator.

2) Start -> Run "services.msc"

3) Right click the service wampapache go to properties and set star-tup type to 'Automatic'

4) Repeat step 3 but for wampmysqld (if you want MySQL to also be available on startup)

Share