Hi ihr,
ich habe mir ein Applet schreiben lassen, habe selbst bislang von dieser Programmierung keine Ahnung. Das Applet ist in eine PHP Datei eingebunden, bekommt Usernamen, Passwort und den Pfad übergeben. Unter Win / Linux läuft dieses Applet einwandfrei. Unter Mac erscheint nur ein Kreuz. Vermutlich liegt dies daran, dass unter Mac nur die 1.5er Version verfügbar ist und nicht die 1.6er. Leider ist der gute Mann, der mir das Applet schrieb ratlos und spielt toter Mann.
Ich suche nun Hilfe von einem Wissenden in dieser Programmiersprache, der mir das Applet so umschreibt, dass es auch in der 1.5er Umgebung des Safari auf Mac ausgeführt und geladen werden kann. Oder alternativ, mir sagt, schreibt, wie ich den Quellcode ändern muss, damit es funzt. Wie schon geschrieben, ich bin bislang in der Programmierung von JavaApplets ein absoluter Dummie. (Meine Domäne sind PHP-Programmierungen). Ich kann nur vermuten, dass hier Klassen, Methoden angesprochen werden, die es zwar in der 1.6er gibt, aber in den früheren Versionen nicht.
Immerhin habe ich die Quellen bekommen, hab mir gerade den JCreator geladen, werde aber nicht wirklich schlauer aus dem Anblick.
Hier nun die Scripte, damit ihr euch ein Bild machen könnt, das Applet besteht aus fünf Dateien:
AppletFTP.java
Upload.java
UploadLauscher.java
PrintCommandListener.java
DurchsuchenLauscher.java
Um es zu testen habe ich dass Applet mal in eine Testumgebung eingebaut:
http://sci-testserver.lw-s10.sci-net.de/upload.php
Achtung, das Verbinden dauert ein Weilchen, der Server ist halt ein Testsystem!
Ich wäre sehr froh, wenn jemand mir helfen könnte oder dieses Problem schlicht lösen könnte!
Viele Grüße
Rainer
ich habe mir ein Applet schreiben lassen, habe selbst bislang von dieser Programmierung keine Ahnung. Das Applet ist in eine PHP Datei eingebunden, bekommt Usernamen, Passwort und den Pfad übergeben. Unter Win / Linux läuft dieses Applet einwandfrei. Unter Mac erscheint nur ein Kreuz. Vermutlich liegt dies daran, dass unter Mac nur die 1.5er Version verfügbar ist und nicht die 1.6er. Leider ist der gute Mann, der mir das Applet schrieb ratlos und spielt toter Mann.
Ich suche nun Hilfe von einem Wissenden in dieser Programmiersprache, der mir das Applet so umschreibt, dass es auch in der 1.5er Umgebung des Safari auf Mac ausgeführt und geladen werden kann. Oder alternativ, mir sagt, schreibt, wie ich den Quellcode ändern muss, damit es funzt. Wie schon geschrieben, ich bin bislang in der Programmierung von JavaApplets ein absoluter Dummie. (Meine Domäne sind PHP-Programmierungen). Ich kann nur vermuten, dass hier Klassen, Methoden angesprochen werden, die es zwar in der 1.6er gibt, aber in den früheren Versionen nicht.
Immerhin habe ich die Quellen bekommen, hab mir gerade den JCreator geladen, werde aber nicht wirklich schlauer aus dem Anblick.
Hier nun die Scripte, damit ihr euch ein Bild machen könnt, das Applet besteht aus fünf Dateien:
AppletFTP.java
Code:
import java.applet.Applet;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
public class AppletFTP extends Applet
{
private JTextField datei;
private JTextField status;
private JButton auswahl;
private JButton upload;
private String pfad;
private String hostname = "87.139.88.77";
private String user = "webmaster";
private String password = "";
private String dir = "web";
private JProgressBar bar;
public void init()
{
this.hostname = getParameter("hostname");
this.user = getParameter("user");
this.password = getParameter("password");
this.dir = getParameter("dir");
if ((this.hostname.equals("")) || (this.user.equals("")) ||
(this.password.equals("")) || (this.dir.equals(""))) {
JLabel lable = new JLabel("Bitte geben Sie die Parameter an!");
add(lable);
}
this.bar = new JProgressBar();
this.auswahl = new JButton("Durchsuchen");
this.auswahl.addActionListener(new DurchsuchenLauscher(this));
this.upload = new JButton("Upload");
this.upload.addActionListener(new UploadLauscher(this));
this.datei = new JTextField(12);
this.status = new JTextField(12);
this.status.setEditable(false);
add(this.auswahl);
add(this.datei);
add(this.upload);
add(this.status);
add(this.bar);
Color c = new Color(228, 241, 235);
setBackground(c);
setVisible(true);
}
public void setTextField(String text)
{
this.datei.setText(text);
}
public String getTextField()
{
return this.datei.getText();
}
public void setPfad(String pfad) {
this.pfad = pfad;
}
public String getStatusField()
{
return this.status.getText();
}
public void setStatusField(String status) {
this.status.setText(status);
}
public String getPfad() {
return this.pfad;
}
public String getHostname() {
return this.hostname;
}
public String getUser() {
return this.user;
}
public String getPassword() {
return this.password;
}
public String getDir() {
return this.dir;
}
public JProgressBar getBar() {
return this.bar;
}
}
Upload.java
Code:
import javax.swing.JProgressBar;
public class Upload extends Thread
{
private AppletFTP a;
private JProgressBar pbar;
public Upload(AppletFTP a, JProgressBar pbar)
{
this.a = a;
this.pbar = pbar;
}
// ERROR //
public void run()
{
// Byte code:
// 0: aload_0
// 1: getfield 17 Upload:pbar Ljavax/swing/JProgressBar;
// 4: new 24 java/io/File
// 7: dup
// 8: aload_0
// 9: getfield 15 Upload:a LAppletFTP;
// 12: invokevirtual 26 AppletFTP:getPfad ()Ljava/lang/String;
// 15: invokespecial 32 java/io/File:<init> (Ljava/lang/String;)V
// 18: invokevirtual 35 java/io/File:length ()J
// 21: l2i
// 22: invokevirtual 39 javax/swing/JProgressBar:setMaximum (I)V
// 25: aload_0
// 26: getfield 17 Upload:pbar Ljavax/swing/JProgressBar;
// 29: iconst_0
// 30: invokevirtual 45 javax/swing/JProgressBar:setValue (I)V
// 33: aload_0
// 34: getfield 17 Upload:pbar Ljavax/swing/JProgressBar;
// 37: iconst_1
// 38: invokevirtual 48 javax/swing/JProgressBar:setStringPainted (Z)V
// 41: iconst_0
// 42: istore_1
// 43: iconst_0
// 44: istore_2
// 45: aload_0
// 46: getfield 15 Upload:a LAppletFTP;
// 49: invokevirtual 52 AppletFTP:getHostname ()Ljava/lang/String;
// 52: astore_3
// 53: aload_0
// 54: getfield 15 Upload:a LAppletFTP;
// 57: invokevirtual 55 AppletFTP:getUser ()Ljava/lang/String;
// 60: astore 4
// 62: aload_0
// 63: getfield 15 Upload:a LAppletFTP;
// 66: invokevirtual 58 AppletFTP:getPassword ()Ljava/lang/String;
// 69: astore 5
// 71: new 61 java/lang/StringBuilder
// 74: dup
// 75: aload_0
// 76: getfield 15 Upload:a LAppletFTP;
// 79: invokevirtual 63 AppletFTP:getDir ()Ljava/lang/String;
// 82: invokestatic 66 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String;
// 85: invokespecial 72 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 88: ldc 73
// 90: invokevirtual 75 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 93: aload_0
// 94: getfield 15 Upload:a LAppletFTP;
// 97: invokevirtual 79 AppletFTP:getTextField ()Ljava/lang/String;
// 100: invokevirtual 75 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 103: invokevirtual 82 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 106: astore 6
// 108: aload_0
// 109: getfield 15 Upload:a LAppletFTP;
// 112: invokevirtual 26 AppletFTP:getPfad ()Ljava/lang/String;
// 115: astore 7
// 117: iconst_1
// 118: istore_1
// 119: iconst_1
// 120: istore_2
// 121: new 85 org/apache/commons/net/ftp/FTPClient
// 124: dup
// 125: invokespecial 87 org/apache/commons/net/ftp/FTPClient:<init> ()V
// 128: astore 8
// 130: aload 8
// 132: aload_3
// 133: invokevirtual 88 org/apache/commons/net/ftp/FTPClient:connect (Ljava/lang/String;)V
// 136: aload_0
// 137: getfield 15 Upload:a LAppletFTP;
// 140: new 61 java/lang/StringBuilder
// 143: dup
// 144: ldc 91
// 146: invokespecial 72 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 149: aload_3
// 150: invokevirtual 75 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 153: ldc 93
// 155: invokevirtual 75 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 158: invokevirtual 82 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 161: invokevirtual 95 AppletFTP:setStatusField (Ljava/lang/String;)V
// 164: aload 8
// 166: invokevirtual 98 org/apache/commons/net/ftp/FTPClient:getReplyCode ()I
// 169: istore 9
// 171: iload 9
// 173: invokestatic 102 org/apache/commons/net/ftp/FTPReply:isPositiveCompletion (I)Z
// 176: ifne +18 -> 194
// 179: aload 8
// 181: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 184: aload_0
// 185: getfield 15 Upload:a LAppletFTP;
// 188: ldc 111
// 190: invokevirtual 95 AppletFTP:setStatusField (Ljava/lang/String;)V
// 193: return
// 194: aload 8
// 196: aload 4
// 198: aload 5
// 200: invokevirtual 113 org/apache/commons/net/ftp/FTPClient:login (Ljava/lang/String;Ljava/lang/String;)Z
// 203: ifne +28 -> 231
// 206: aload 8
// 208: invokevirtual 117 org/apache/commons/net/ftp/FTPClient:logout ()Z
// 211: pop
// 212: aload 8
// 214: invokevirtual 121 org/apache/commons/net/ftp/FTPClient:isConnected ()Z
// 217: ifeq +13 -> 230
// 220: aload 8
// 222: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 225: goto +5 -> 230
// 228: astore 16
// 230: return
// 231: iload_2
// 232: ifeq +10 -> 242
// 235: aload 8
// 237: iconst_2
// 238: invokevirtual 124 org/apache/commons/net/ftp/FTPClient:setFileType (I)Z
// 241: pop
// 242: aload 8
// 244: invokevirtual 127 org/apache/commons/net/ftp/FTPClient:enterLocalPassiveMode ()V
// 247: iload_1
// 248: ifeq +108 -> 356
// 251: new 130 java/io/FileInputStream
// 254: dup
// 255: aload 7
// 257: invokespecial 132 java/io/FileInputStream:<init> (Ljava/lang/String;)V
// 260: astore 10
// 262: new 130 java/io/FileInputStream
// 265: dup
// 266: aload 7
// 268: invokespecial 132 java/io/FileInputStream:<init> (Ljava/lang/String;)V
// 271: astore 10
// 273: aload 8
// 275: aload 6
// 277: invokevirtual 133 org/apache/commons/net/ftp/FTPClient:storeFileStream (Ljava/lang/String;)Ljava/io/OutputStream;
// 280: astore 11
// 282: iconst_0
// 283: istore 12
// 285: sipush 1000
// 288: newarray byte
// 290: astore 13
// 292: goto +29 -> 321
// 295: aload 11
// 297: aload 13
// 299: iconst_0
// 300: iload 14
// 302: invokevirtual 137 java/io/OutputStream:write ([BII)V
// 305: iload 12
// 307: iload 14
// 309: iadd
// 310: istore 12
// 312: aload_0
// 313: getfield 17 Upload:pbar Ljavax/swing/JProgressBar;
// 316: iload 12
// 318: invokevirtual 45 javax/swing/JProgressBar:setValue (I)V
// 321: aload 10
// 323: aload 13
// 325: invokevirtual 143 java/io/InputStream:read ([B)I
// 328: dup
// 329: istore 14
// 331: ifge -36 -> 295
// 334: aload 10
// 336: invokevirtual 149 java/io/InputStream:close ()V
// 339: aload 11
// 341: invokevirtual 152 java/io/OutputStream:close ()V
// 344: aload_0
// 345: getfield 15 Upload:a LAppletFTP;
// 348: ldc 153
// 350: invokevirtual 95 AppletFTP:setStatusField (Ljava/lang/String;)V
// 353: goto +29 -> 382
// 356: new 155 java/io/FileOutputStream
// 359: dup
// 360: aload 7
// 362: invokespecial 157 java/io/FileOutputStream:<init> (Ljava/lang/String;)V
// 365: astore 10
// 367: aload 8
// 369: aload 6
// 371: aload 10
// 373: invokevirtual 158 org/apache/commons/net/ftp/FTPClient:retrieveFile (Ljava/lang/String;Ljava/io/OutputStream;)Z
// 376: pop
// 377: aload 10
// 379: invokevirtual 152 java/io/OutputStream:close ()V
// 382: aload 8
// 384: invokevirtual 117 org/apache/commons/net/ftp/FTPClient:logout ()Z
// 387: pop
// 388: goto +86 -> 474
// 391: astore 10
// 393: aload_0
// 394: getfield 15 Upload:a LAppletFTP;
// 397: ldc 162
// 399: invokevirtual 95 AppletFTP:setStatusField (Ljava/lang/String;)V
// 402: aload 8
// 404: invokevirtual 121 org/apache/commons/net/ftp/FTPClient:isConnected ()Z
// 407: ifeq +13 -> 420
// 410: aload 8
// 412: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 415: goto +5 -> 420
// 418: astore 16
// 420: return
// 421: astore 10
// 423: aload_0
// 424: getfield 15 Upload:a LAppletFTP;
// 427: ldc 164
// 429: invokevirtual 95 AppletFTP:setStatusField (Ljava/lang/String;)V
// 432: aload 8
// 434: invokevirtual 121 org/apache/commons/net/ftp/FTPClient:isConnected ()Z
// 437: ifeq +13 -> 450
// 440: aload 8
// 442: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 445: goto +5 -> 450
// 448: astore 16
// 450: return
// 451: astore 15
// 453: aload 8
// 455: invokevirtual 121 org/apache/commons/net/ftp/FTPClient:isConnected ()Z
// 458: ifeq +13 -> 471
// 461: aload 8
// 463: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 466: goto +5 -> 471
// 469: astore 16
// 471: aload 15
// 473: athrow
// 474: aload 8
// 476: invokevirtual 121 org/apache/commons/net/ftp/FTPClient:isConnected ()Z
// 479: ifeq +45 -> 524
// 482: aload 8
// 484: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 487: goto +37 -> 524
// 490: astore 16
// 492: goto +32 -> 524
// 495: astore 9
// 497: aload 8
// 499: invokevirtual 121 org/apache/commons/net/ftp/FTPClient:isConnected ()Z
// 502: ifeq +13 -> 515
// 505: aload 8
// 507: invokevirtual 108 org/apache/commons/net/ftp/FTPClient:disconnect ()V
// 510: goto +5 -> 515
// 513: astore 10
// 515: aload_0
// 516: getfield 15 Upload:a LAppletFTP;
// 519: ldc 166
// 521: invokevirtual 95 AppletFTP:setStatusField (Ljava/lang/String;)V
// 524: return
//
// Exception table:
// from to target type
// 220 225 228 java/io/IOException
// 194 212 391 org/apache/commons/net/ftp/FTPConnectionClosedException
// 231 388 391 org/apache/commons/net/ftp/FTPConnectionClosedException
// 410 415 418 java/io/IOException
// 194 212 421 java/io/IOException
// 231 388 421 java/io/IOException
// 440 445 448 java/io/IOException
// 194 212 451 finally
// 231 402 451 finally
// 421 432 451 finally
// 461 466 469 java/io/IOException
// 482 487 490 java/io/IOException
// 130 193 495 java/io/IOException
// 194 230 495 java/io/IOException
// 231 420 495 java/io/IOException
// 421 450 495 java/io/IOException
// 451 492 495 java/io/IOException
// 505 510 513 java/io/IOException
}
}
UploadLauscher.java
Code:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class UploadLauscher
implements ActionListener
{
private AppletFTP a;
public UploadLauscher(AppletFTP a)
{
this.a = a;
}
public void actionPerformed(ActionEvent arg0) {
Upload up = new Upload(this.a, this.a.getBar());
up.start();
}
}
PrintCommandListener.java
Code:
import java.io.PrintWriter;
import org.apache.commons.net.ProtocolCommandEvent;
import org.apache.commons.net.ProtocolCommandListener;
public class PrintCommandListener
implements ProtocolCommandListener
{
private PrintWriter __writer;
public PrintCommandListener(PrintWriter writer)
{
this.__writer = writer;
}
public void protocolCommandSent(ProtocolCommandEvent event)
{
this.__writer.print(event.getMessage());
this.__writer.flush();
}
public void protocolReplyReceived(ProtocolCommandEvent event)
{
this.__writer.print(event.getMessage());
this.__writer.flush();
}
}
DurchsuchenLauscher.java
Code:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JFileChooser;
public class DurchsuchenLauscher
implements ActionListener
{
private AppletFTP a;
public DurchsuchenLauscher(AppletFTP a)
{
this.a = a;
}
public void actionPerformed(ActionEvent arg0) {
JFileChooser fc = new JFileChooser();
int state = fc.showOpenDialog(null);
if (state == 0)
{
File file = fc.getSelectedFile();
this.a.setTextField(file.getName());
this.a.setPfad(file.getPath());
}
}
}
http://sci-testserver.lw-s10.sci-net.de/upload.php
Achtung, das Verbinden dauert ein Weilchen, der Server ist halt ein Testsystem!
Ich wäre sehr froh, wenn jemand mir helfen könnte oder dieses Problem schlicht lösen könnte!
Viele Grüße
Rainer