Red5 + Java + Windows installation + ant compilation: it works, but why?
I am completely new to the java and java Server worlds ... But I have good knowledge (17 years) of object oriented programming. My question is:
Why do I need to call ant for it to work (see later, if you're not interested, skip my question ^ _ ^)?
Here I want to: create a simple application that can do video conferencing (= server receives one client video stream and sends it to client X). I wanted it for free (Adobe Server costs roughly $ 10,000). The only solution I have found is Red5 (see there )
I downloaded and installed version 0.7. Here are the steps I took to successfully compile java app for Red5:
- download and install (Windows XP) latest version (0.7)
- Download and copy manually to install folder with some files forgotten in 0.7 install (compare to v0.6 release and guess which ones) (
ivy.xml
if I remember) - go to the folder
[Red5 path]\webapps
. Copy / paste the foldertutorial
. - rename the folder to
myapp
. - edit all xml files in this folder, find the line
tutorial
and rename it tomyapp
- here is what i did and did not work: compile with javac:
javac -classpath "[Red5 path]\red5.jar" -d "[Red5 path]\webapps\myapp\WEB-INF\classes" Application.java javac -classpath "[Red5 path]\red5.jar" -d "[Red5 path]\webapps\myapp\WEB-INF\classes" TestService.java
- Everything worked fine, but as soon as I started the Flex client the response from the server was "Invalid application"
-
After many tries I found that removing everything except this code works:
package myapp; import org.red5.server.adapter.ApplicationAdapter; import org.red5.server.api.IConnection; import org.red5.server.api.IScope; /* myapp */ public class Application extends ApplicationAdapter {
public String sayHello(Object[] params){ return "got : " + params[0].toString(); }
} >
Then I then wanted to follow.
-
I wrote some code that worked in Red5 examples:
package myapp;
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.red5.server.adapter.ApplicationAdapter; import org.red5.server.api.IConnection; import org.red5.server.api.IScope;
public class Application extends ApplicationAdapter {
protected static Logger log = LoggerFactory.getLogger(Application.class); public String sayHello(Object[] params){ log.info("I got your name: "+params[0].toString()); return "I got your name: " + params[0].toString(); }
} Code>
-
After restarting server Red5: I always got this response from the server: "Invalid application"
- Then I downloaded ant , unpacked it into
[Red5 path]
- I created a new file
[Red5 path]\webapps\myapp\WEB-INF\build.xml
- I added this xml to it:
<project name="Projet myapp" default="compile" basedir=".">
<target name="clean" description="Clean output directories">
</target>
<target name="compile" depends="clean">
<javac srcdir="./src" destdir="./classes" source="1.6" classpath="C:\Program Files\Red5\red5.jar" >
</javac>
</target>
<target name = "jar" depends ="compile">
<echo message ="Creating jar..."/>
<jar destfile="./lib/myapp.jar" basedir="./classes"/>
<echo message ="Done."/>
</target>
</project>
- Start a shell, then enter:
cd [Red5 path]\webapps\myapp\WEB-INF ......\apache-ant-1.7.1\bin\ant jar
- Everything works perfectly!
- Here is the question!
- I don't understand:
Why would I call ant to make it work?
a source to share