Monday, November 16, 2015

Deploy Servlets on Eclipse on Ubuntu - links to help.

How to deploy Servlets via Eclipse on Ubuntu -- start here
http://www.codejava.net/ides/eclipse/how-to-create-deploy-and-run-java-servlet-in-eclipse

If you run into problems then go here -- (I was using tomcat v7.0)
http://stackoverflow.com/questions/13423593/eclipse-4-2-juno-cannot-create-a-server-using-the-selected-type-in-tomcat-7

Last, if you have permissions preventing you to run the web application, close the eclipse and run it as admin. it will by-pass some of the restrictions with deployments. In the eclipse application directory, type:  sudo ./eclipse and it will run as admin.

Tomecat v7.0 Server, Eclipse, and Ubuntu. Server Name is blank when defining a new server

Problem: 
Tomecat v7.0 Server, Eclipse, and Ubuntu. When you Define a new Server and choose tomcat v7.9, the Server host name is populated however the server name is blank. It is expected to be something like "Tomecat v7.0 Server at localhost"

Solution:
  1. Close Eclipse
  2. In {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings. delete the following:
    • org.eclipse.wst.server.core.prefs
    • org.eclipse.jst.server.tomcat.core.prefs
  3. Restart Eclipse
Source (thanks whoever wrote the solution):
http://crunchify.com/eclipse-how-to-fix-installing-apache-tomcat-server-issue-blank-server-name-field/

Sunday, November 8, 2015

Very simple Java String methods: "Split String" and "Capitalize the First Letter "

// Some common simple Java String methods: "Split String" and "Capitalize the First Letter " 

// Split Strings, just like the String split method, but it removes all white spaces.
// I expect a million other implementation of this, but this does the job as well.
public static String[] splitString(String text, String splitChar){
String [] list = text.split(splitChar);

for (int i=0; i<list.length; i++){
list[i] = list[i].trim();
}
return list;
}

// Capitalize the First Letter of the passed in String s
public static String capitalizeFirstLetter(String s){
String result = null;

if (s != null){
if (s.length() >1)
result = s.substring(0, 1).toUpperCase() + s.substring(1, s.length());
else
result = s.toUpperCase();
}
return result;
}