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 :
ivy.xml
if I remember)[Red5 path]\webapps
folder. Copy /
paste the tutorial
folder.myapp
.tutorial
and rename it to myapp
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
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"
[Red5 path]
[Red5 path]\webapps\myapp\WEB-INF\build.xml
<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>
cd [Red5 path]\webapps\myapp\WEB-INF
......\apache-ant-1.7.1\bin\ant jar
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.