-
March 17th, 2010, 12:55 AM
#1
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?
-
March 17th, 2010, 05:15 AM
#2
Re: Chilkat Upload not compiling
Originally Posted by savagenoob
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 [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
March 19th, 2010, 12:16 AM
#3
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;" ?
-
March 19th, 2010, 06:03 AM
#4
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 [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
March 19th, 2010, 09:41 AM
#5
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!
-
March 19th, 2010, 03:48 PM
#6
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.
-
March 19th, 2010, 03:58 PM
#7
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!
-
March 24th, 2010, 12:23 AM
#8
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.
-
March 24th, 2010, 11:48 AM
#9
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.
-
March 27th, 2010, 12:49 AM
#10
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?
-
March 27th, 2010, 11:03 AM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|