Firefox Extension - Write text in file in your extension's folder

Below is a code sample showing how to write text in file(data.txt) in your extension's folder.

Note:

Firefox Extension - Invoke Java code from Javascript

Standard Java Classes To use the standard Java classes from Javascript, there are only 2 steps:

  1. Insert Packages in front of the fully qualified name of the Java class that you would like to use.
  2. Assign that fully qualified class name to a local variable.

Here is simple example illustrating the 2 steps:

var myJsVariable = new Packages.java.util.ArrayList();    


Another more complex example:  

Firefox Extension

Firefox Extension tutorial

Firefox Extension - Ant build file to package Firefox's extension

Below is an example of Ant build file to package Firefox's extension.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="yourFirefoxExtName">
  <target name="build">
    <!-- JAR the content of your chrome/ folder -->
    <jar destfile="${ant.project.name}.jar">
      <fileset dir="chrome">
        <exclude name="${ant.project.name}.jar"/>
      </fileset>
    </jar>
 
    <!-- Create XPI file. -->
    <move file="${ant.project.name}.jar" todir="chrome" overwrite="yes" />

Ant

Apache Ant is a Java-based build tool.

Define a variable

TestNG - First TestNG test

Write TestNG test

Writing tests using TestNG is easy. There are only 2 steps:

Java - Setting the class path

This tutorial offers step-by-step instructions on how to set up the class path. I will use selenium-java-client-driver.jar and junit-4.5.jar as examples to show you how to add them to the CLASSPATH.

  1. Depending on the version of your MS Windows, the steps below may be different but similar.
    • If you are using MS Windows XP, then open [Classic View]Control Panel->System->Advanced->Environment Variables.

DOS

WARNING: If you want to learn to write batch script in DOS, stop it right now! Do yourself a favor. Stop reading this tutorial. Unless your are masochist. Please consider other alternative such as Perl. DOS is a pain and the 'language' is not intuitive and not logical.

ECHO

Display string.

Regular Expression - Grep

# Grep tab using Perl regex
grep -P "\t"
 
# Select multiple text patterns(e.g "this" or "that")

Regular Expression - Sed

Helpful Sed one-liners commands.

REM Delete empty line
sed -e "/^$/d" 1x.txt > 2x.txt

REM Delete all newline.( Concatenate each line of 1x.txt into 1 line of string )
sed ":a;N;$!ba;s/\n//g" 1x.txt > 2x.txt
REM http://sed.sourceforge.net/sedfaq5.html#s5.10

REM Print line without 'code'
sed -n "/code/!p" 1x > 2x.txt
REM In bash shell, use single quote.

REM Delete line 2 up to line 10 inclusively.
sed -e "2,10d" 1x.txt > 2x.txt

REM Skip the 3rd line(Replace 'a' with 'b' for all lines except the 3rd line).
sed -e "3n; s/a/b/g" 1x.txt > 2x.txt

Pages

Subscribe to OpenWritings.net RSS