CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2010
    Posts
    9

    Chilkat Upload not compiling

    I am a noob at Java, but am rapidly learning, I am trying to compile Chilkat's upload class and library but it will not compile. Here is the code:

    <CODE>
    import com.chilkatsoft.CkUpload;

    public class upload {
    static {
    try {
    System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
    System.err.println("Native code library failed to load.\n" + e);
    System.exit(1);
    }
    }

    public static void main(String argv[])
    {
    CkUpload upload = new CkUpload();

    // Specify the page (ASP, ASP.NET, Perl, Python, Ruby, CGI, etc)
    // that will process the HTTP Upload.
    upload.put_Hostname("www.snapmanagerpro.com/PHP-Login");
    upload.put_Path("/receiveUpload.php");

    // Add one or more files to be uploaded.
    upload.AddFileReference("file1","dude.gif");

    // Do the upload. The method returns when the upload
    // is completed.
    // This component also includes asynchronous upload capability,
    // which is demonstrated in another example.
    boolean success;
    success = upload.BlockingUpload();
    if (success != true) {
    System.out.println(upload.lastErrorText());
    }
    else {
    System.out.println("Files uploaded!");
    }

    }

    }
    <\CODE>

    Error in Eclipse:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at upload.main(upload.java:13)

    Error when I use the command line using javac -encoding utf8 -classpath ..\chilkat.jar upload.java
    :

    C:ChilkatJava\chilkatJava\examples>javac -encoding utf8 -classpath ..\chilkat.jar upload.java
    upload.java:1: illegal character: \65279
    ?import com.chilkatsoft.CkUpload;
    ^
    1 error


    Maybe someone can help me pls?

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Chilkat Upload not compiling

    Quote Originally Posted by savagenoob View Post
    upload.java:1: illegal character: \65279
    ?import com.chilkatsoft.CkUpload;
    ^
    1 error
    The error message says there is an illegal character in line 1 of upload.java, immediately preceding the import statement.

    Think twice, code once...
    Anon.
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Mar 2010
    Posts
    9

    Re: Chilkat Upload not compiling

    Hm, but I copied my code verbatim, do you see any character that would throw that error in "import com.chilkatsoft.CkUpload;" ?

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Chilkat Upload not compiling

    I only see what the browser shows me. If the compiler says there is an invalid character in the code, there is an invalid character in the code. When you copy code from web pages, it isn't unusual to get odd characters that the compiler doesn't understand. Sometimes they look like spaces, and sometimes they are non-printing characters. This may be what has happened.

    The solution is to edit the offending line(s) to ensure they are clean. If your editor doesn't display the unwanted character(s), find one that does. Notepad will display most as squares, and Textpad as blocks. If all else fails, rewrite the offending lines by hand.

    Bad code isn't bad, its just misunderstood...
    Anon.
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  5. #5
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Chilkat Upload not compiling

    Copied your code from above and pasted into an editor. Saved it and downloaded the chilkat jar from their site. Then I compiled on command line with
    Code:
    $JAVA_HOME/bin/javac -cp ./chilkat.jar Upload.java
    It built just fine. You should be able to do the same.

    BTW, code tags need square brackets -- [ ] not pointy ones <>, but thanks for trying!

  6. #6
    Join Date
    Mar 2010
    Posts
    9

    Re: Chilkat Upload not compiling

    Yeah, I suck so bad I cant even code on codeguru forums! lolzershitz. Thanks guys. Will try when I get home and cross my fingers that I can figure it out.

  7. #7
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Chilkat Upload not compiling

    No worries, at least you made the effort, that's more than some know or try to do.

    I really wasn't criticizing, I thought you might be wondering why the code block didn't work.

    If nothing else, you can do as I did and copy what's here to a new source file. It should build.

    Good luck!

  8. #8
    Join Date
    Mar 2010
    Posts
    9

    Re: Chilkat Upload not compiling

    Question, I got this to compile and run fine, but isnt the lines:

    upload.put_Hostname("www.snapmanagerpro.com");
    upload.put_Path("/PHP-Login/receiveUpload.php");

    supposed to pop that page up for me to process the upload? What am I missing here. When I run it, it says "Files Uploaded!" but there is nothing there and receiveUpload.php does not pop up.

  9. #9
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Chilkat Upload not compiling

    You would have to check the documentation and/or JavaDoc for the libraries you're using. Not everyone here is an expert on every library out there.

    That being said, my guess would be that this just takes some list of files you provide and uploads them to the site and path specified in the code. If you want to provide a selector for files, you'll need to provide that in your code, then pass the result from the selector to the upload.addFileReference method.

  10. #10
    Join Date
    Mar 2010
    Posts
    9

    Re: Chilkat Upload not compiling

    Thats what my guess was to, am I mistaken into thinking this could upload a file on a client computer to the webserver via http? is this possible or is FTP the only option to upload to a webserver?

  11. #11
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Chilkat Upload not compiling

    I believe that would depend on what the server owners have implemented.

    HTTP might not be open for file upload for security reasons. Having FTP open is often bad enough.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured