Friday, May 30, 2008

Latex in Windows

  • download Tex distribution (usually MikTex (http://www.miktex.org/) )
  • download and install the LeD latex editor

Using command line
  • create using any text editor and save the file with extension (.tex)
  • to create the div file that can be viewed use the command (latex file.tex)
  • to convert div file into pdf (dvipdfm file.div)
  • for Windows use the software MikTex

How to generate PDF file

if you want to convert the latex into pdf (in Miketex) it will not recognize the .eps pictures. You can press DVI-> PDF which will convert the file into pdf without the need to change all the picture files into png extension.

Using Led Editor

You will see the pdf result immediately on the right opf the screen, also you can click on the pdf to reach to specific pieces on the tex file.

Just press the green button (Latex Compilation)

How to use references file (bib) in LED editor?

Getting current Latex document to use your .bib file is not actually very difficult. At the end of your Latex file (that is, after the content, but before \end{document}, you need to place the following commands:

\bibliographystyle{plain}
\bibliography{sample}

where sample is sample.bib

Now in Led editor you never complie the .bib file, just the .tex file.

Open up the .tex file and compile it using Latex then compile it using Bibtex

You might then have to compile it again using Latex to finish the process.

Printing the URL Field

In order to printout URL’s, you can make use of the howpublished field. Try this: howpublished = {\url{http://texblog.wordpress.com}},
You will have to add the url-package to your tex-document: \usepackage{url}.

How to keep Capitalization in the title field?
surrounded by extra brackets to preserve the capitalization.without changing the way it appears in the bibliography. by adding extra curly brackets around some characters

How to Fix the problem of figures not shown in LED DVI viewer?

Check the gsdll32.dll path in LED->menu->Configuration->options->Application->DVI viewer->GSDL32.dll directory. Make sure that the path points to the right GSView bin directory.

Wrapping Figures

Although not normally the case in academic writing, an author may prefer that some floats do not break the flow of text, but instead allow text to wrap around it. (Obviously, this effect only looks decent when the figure in question is significantly narrower than the text width.) The package wrapfig was developed for this very task.

To use wrapfig, you must first add \usepackage{wrapfig} to the preamble. This then gives you access to the \begin{wrapfigure}{alignment}{width} command. Alignment can be either l for left, or r for right. The width is obviously the width of the figure. An example:

\begin{wrapfigure}{r}{40mm}
\begin{center}
\includegraphics{toucan.eps}
\end{center}
\caption{The Toucan}
\end{wrapfigure}




Make a folder tree myowntexmf\tex\latex\mystyles

Put the file in mystyles and then add myowntexmf as a new local root
in miktex settings.



Errors

  1. "Misplaced alignment tab character &".

  2. In LaTeX, the "&" character is used for tabbing (alignment) in certain environments, but it is not a legal character on its own; that is what the first line of the error message above is saying - that the character "&" is being used somewhere it shouldn't. Click "Go To Error" to go to the place where the compiler thinks there is an error in the editing window.

Tuesday, May 20, 2008

Increase Heap in Eclipse

From Eclipse
Project -> Properties->Run/Debug setting -> Edit ->Arguments ->VM arguments (-Xmx256M)

From command line
java -Xms32m -Xmx128m

In Tomcat

Edit bin/Catalania.bat add -Xmx256m to JAVA_OPTS

Sunday, May 18, 2008

Eclipse + Servlet +Tomcat

For Tomcat version 6.0 and Eclipse version 3.3.0

You have to manually import context.xml from location
C:\Tomcat-6.0\conf\
to
MyWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf
and then changes to
Context reloadable="true"
and
privileged="true"

Now how to run servlets on Eclipse:

1- New "Dynamic web Project"
2- new -> Target run time -> choose tomcat server and its main folder as the source path.
3- R-click on the project -> new ->servlet (no need to have package name)
4- R-click on the servelt Java file and Run-as server

For the servlet to work the class file has to be in
/tomcat/webapps/project/web-inf/classes

and the HTML file (
with FORM METHOD=GET ACTION="Hello" , where Hello is the servlet name)can be in

/tomcat/webapps/project/

You can have multiple servlets defined inside web.xml, each one will be inside the servet tag.



Saturday, May 17, 2008

Servlets

  1. Servlets are simply .class files, i.e., compiled .java files.
  2. Servlet files are stored in the WEB-INF/classes subdirectory of the main web application directory. In this case the .class files for the examples web app is stored in %TOMCAT_HOME%/webapps/examples/WEB-INF/classes.
  3. So when the user requests
    http://localhost:8080/examples/servlet/HelloWorldExample
    Tomcat runs
    %TOMCAT_HOME%/webapps/examples/WEB-INF/classes/HelloWorldExample.class



  • Create a folder inside webppas of Tomcat server (star, for example)
  • "\WEB-INF\classes" is the folder to keep Servlet class files
  • 'web.xml' is saved in the '/WEB-INF' folder
  • Compile command
javac -cp %CATALINA_HOME%\lib\servlet-api.jar TestServlet.java


The url to access the servlet , after starting Tomcat server

http://localhost:8080/star/TestServlet

------------------------------------------------
1- must run Tomcat server then try http://localhost:8080 to verify it works
2- There is a specific structure for the files
/webapps/myApp/WEB-INF/classes/ will contain java classes
/webapps/myApp/WEB-INF/src/ will contain the source
/webapps/myApp/script/ will contain other script code

3-assign your servlet class to a package, for example at the beginning of the Java file
package org.oats;


4- Need to tell were the servlets resides (the path classes) using web.xml
which is saved in /webapps/myApp/WEB-INF/web.xml



Ontology
Ontology


org.oats.OntologyServlet



Finally, again in the web.xml file, add:


Ontology


/Ontology



That says "When you see the URL /Ontology, call the Servlet name "Ontology",
which is mapped to the 'org.oats.OntologyServlet' class".


5- the two main methods to implement in servlets are doGet and doPost

Monday, May 12, 2008

Mod Python (using python in the web)

Mod_python is an Apache module that embeds the Python interpreter within the server. With mod_python you can write web-based applications in Python that will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections and other data between hits and access to Apache internals.

ModPython

How to install:

1-Download binaries for windows
2-run the installer (must have installed Python and Apache server , with same versions compatabile with the version of modPython)
3- Choose place of where Python is installed
4- Add the line into conf/httpd.conf
LoadModule python_module modules/mod_python.so

5- Add the following as a new Directory tags in the file conf/httpd.conf (Directory is a tag < >)

Directory "E:\moodle\moodle\PythonTest"
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
/Directory

Now to test it create a file with .py inside the root of apache, it will execute the function with the name handler.

To Work With forms

PythonHandler mod_python.publisher

It will pass the form into the the .py file into the function name index(), with the same names of the fields.

Thursday, May 8, 2008

How to use protege OWL API in Eclipse

1-Create Java Project
2-Goto Project->Properties-> Java Build Paths

Libraries tab, click add external JARS and go
inside Protege directory ->select all jar files.
inside Protege directory ->Plugins inside (edu.stanford.smi.protegex.owl) select all jar files.
Also
Select protege.api from /protege/


in Java code

import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.model.*;