Estou usando o JAVAC (JDK6) + Sublime Text 2 + Ubuntu
VARIAVEIS DE AMBIETE:
[quote]rafael@rafael-note:~$ echo $JAVA_HOME
/usr/java/jdk1.6.0_34
rafael@rafael-note:~$ echo $CLASSPATH
/usr/java/jdk1.6.0_34/lib
rafael@rafael-note:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/java/jdk1.6.0_34/bin[/quote]
tree do meu projeto
[quote].
├── class
│ └── com
│ ├── client
│ │ └── Cliente.class
│ ├── commom
│ │ └── Conversor.class
│ └── server
│ ├── ConnectionManager.class
│ ├── Converter.class
│ ├── Converter_Stub.class
│ └── Servidor.class
├── doc
├── lib
│ ├── commons-cli-1.2.jar
│ ├── commons-io-1.4.jar
│ ├── DEPENDENCIES.txt
│ ├── jodconverter-2.2.2.jar
│ ├── jodconverter-cli-2.2.2.jar
│ ├── juh-3.0.1.jar
│ ├── jurt-3.0.1.jar
│ ├── ridl-3.0.1.jar
│ ├── slf4j-api-1.5.6.jar
│ ├── slf4j-jdk14-1.5.6.jar
│ ├── unoil-3.0.1.jar
│ └── xstream-1.3.1.jar
├── pdf
└── src
├── Cliente.java
├── ConnectionManager.java
├── Conversor.java
├── Converter.java
└── Servidor.java[/quote]
comando usado pra compilar os (.java)
classes:
[code]package com.commom;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Conversor extends Remote {
public void converter(byte[] doc) throws RemoteException;
public byte[] getPDF() throws RemoteException;
}[/code]
[code]package com.server;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import com.commom.Conversor;
import java.io.;
import java.util.;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
public class Converter extends UnicastRemoteObject implements Conversor {
private byte[] pdfbin;
private OpenOfficeConnection manager;
private File doc;
private File pdf;
public Converter() throws RemoteException {
this.doc = new File("doc/" + new Date().getMinutes());
this.pdf = new File("pdf/" + new Date().getMinutes());
}
public void converter(byte[] docbin) throws RemoteException {
receive(docbin);
connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(manager);
converter.convert(this.doc, this.pdf);
disconnect();
}
private void receive(byte[] archive){
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(this.doc));
bos.write(archive);
bos.close();
} catch (Exception e){
System.out.println(e.getMessage());
}
}
private byte[] response(){
FileInputStream stream = null;
byte[] binary = null;
try {
stream = new FileInputStream(this.pdf);
int length = 0;
while((length = stream.read(binary)) != -1) {
System.out.println("CARREGANDO");
}
stream.close();
} catch(Exception e){
System.out.println(e.getMessage());
}
return binary;
}
public byte[] getPDF() throws RemoteException {
return response();
}
private void connect(){
try {
this.manager = ConnectionManager.getCurrentInstance();
this.manager.connect();
} catch (Exception e) {
e.printStackTrace();
}
}
private void disconnect(){
this.manager.disconnect();
}
}[/code]
[code]package com.server;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import java.io.Serializable;
// criando um singleton, so deve existir uma unica instancia de conexao
public class ConnectionManager implements Serializable {
private static OpenOfficeConnection manager = null;
public static OpenOfficeConnection getCurrentInstance(){
if(manager == null) {
manager = new SocketOpenOfficeConnection(8100);
}
return manager;
}
private ConnectionManager() {
}
}[/code]
[code]package com.server;
import java.rmi.Naming;
import com.commom.Conversor;
public class Servidor {
public static void main(String[] args){
try {
Conversor converter = new Converter();
Naming.bind("rmi://localhost/conversor", converter);
} catch(Exception e){
System.out.println(e.getMessage());
}
}
}[/code]
[code]package com.client;
import java.rmi.;
import com.server.;
import com.commom.*;
public class Cliente {
public static void main(String[] args) throws Exception {
Conversor conversor = (Conversor) Naming.lookup("rmi://localhost/conversor");
}
}[/code]
agora vou criar o stub:
gera esse erro: [quote]rafael@rafael-note:~/Dropbox/Public/java/class$ rmic com.server.Converter
error: Class com.server.Converter not found.
1 error[/quote]
mas ai eu adicione o classpath ao comando… (eu pensava que ja nao era mais necessario (mas OK, funciona)
boto o RMIREGISTRY pra rodar:
OK… rodando…
agora vou iniciar o servidor:
[quote]rafael@rafael-note:~/Dropbox/Public/java/class$ java -classpath .:…/lib/jodconverter-2.2.2.jar com.server.Servidor
RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.server.Converter_Stub[/quote]
alguem sabe pq o stub nao esta sendo encontrado? :~
ja tentei de tudo… e nada.