I’m totally new to both java and java Server worlds…
But I’ve a good knowledge (17 years) of object-oriented programming.
My question is :
Why do I have to call ant to make it work (see later, if you’re not interested, skip my question ^_^ ) ?
Here’s what I want : create a simple application that can do a videoconference (= the server receives one client video stream and dispatches it to X clients).
I wanted it free (Adobe Server costs something like 10000 dollars).
The only solution I found is Red5 (see there)
I’ve downloaded and installed the 0.7 version.
Here are the steps I did to be able to compile successfully a java application for Red5 :
- download and install (Windows XP)
the latest release (0.7) - download & copy manually in the
install folder some files that have been
forgotten in the 0.7 installation
(compare to the v0.6 release and guess which ones)
(ivy.xmlif I remember) - go in the
[Red5 path]\webappsfolder. Copy /
paste thetutorialfolder. - rename the folder to
myapp. - edit all the xml files in that folder, search the string
tutorial
and rename it tomyapp - here’s what I did and it 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 once I launched the
Flex client the answer from the server was “Invalid Application” -
After many tries I found that removing everything but that code
made everything work :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 be able to trace.
-
I wrote that code that was working in the 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(); }}
-
After restarting Red5 server : I always got that response
from the server: "Invalid application" - Then I downloaded ant, unpacked it in the
[Red5 path] - I've created a new file
[Red5 path]\webapps\myapp\WEB-INF\build.xml - I've put that xml in 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>
- Run a shell, then type :
cd [Red5 path]\webapps\myapp\WEB-INF ......\apache-ant-1.7.1\bin\ant jar
- Everything works fine now !
- Here's the question !
- What I don't understand is :
Why do I have to call ant to make it work ?
Ant will both compile the code (compile target) and build the jar file (target jar), which will be placed in lib folder. When you simply compile the code with javac, the jar file isn’t generated.