There is a tutorial that shows you how to do this with a test certificate. If you want a valid certificate with your company name etc, you will need to purchase one through a certificate provider.
The tutorial on how to create a test certificate and use it to build your Jar file is here:
http://java.sun.com/docs/books/tutorial/deployment/jar/index.html
http://java.sun.com/docs/books/tutorial/deployment/jar/signing.html
thats all it has
his basic form of the command assumes that the keystore to be used is in a file named .keystore in your home directory
it doesnt tell how to make the keystore
if someone has an instant messanger and is willing to help please post
Message was edited by:
ByronTheOmnipotent
To generate a cert, you need to do the following:
keytool -genkeypair -alias myNewKey -storepass changeit -keypass <password_you_want to_use>
the -storepass password is by default changeit, so unless you have changed it, that is what you will need to use.
The -keypass is a password you want to use for the new cert. Just don't loose it.
After issuing this command, just follow the prompts.
i tried creating a keystore earlier but i didnt understand what i was doing...i was reading around and found that keytool command so i tried generating a key and it asked me for my name and all that...can someone please just make me a certifcate or post an instant messenger or something because im only 14 and this stuff is really confusing
Message was edited by:
ByronTheOmnipotent
Message was edited by:
ByronTheOmnipotent
> i tried creating a keystore earlier but i didnt
> understand what i was doing...can someone please just
> make me a certifcate or post an instant messenger or
> something because im only 14 and this stuff is really
> confusing
We cannot -- literally -- do it for you. Follow the advice given to you here. Try searching Google for "create a java certificate" or something of the sort.
alright i got the genkey thing on the new one and i get this error message
http://imagetiki.com/uploads/9a669390ac.png
really all i need is the certificate to sign it with cause i was using someone elses certifcate but it wouldnt let me save to the C:/ still because it didnt have the right persmissions
this is what it looked like in edit pad and the file type was just file
http://imagetiki.com/uploads/291b5b6a40.png
If you have your jar file signed with a certificate, then like Djaunl said, it might be throwing an exception somewhere and you are catching it and not outputing the exception. Even if it is a null pointer exception.
Go through all of your code and find all your catches and make sure you are doing a printStackTrace() on all of them, and then look at the java console to find the errors.
this is what i use to download the files
import java.io.*;
import java.net.*;
/*
* Command line program to download data from URLs and save
* it to local files. Run like this:
* java FileDownload http://schmidt.devlib.org/java/file-download.html
* @author Marco Schmidt
*/
public class FileDownload {
public static void download(String address, String localFileName) {
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
try {
URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream(localFileName));
conn = url.openConnection();
in = conn.getInputStream();
byte[] buffer = new byte[1024];
int numRead;
long numWritten = 0;
while ((numRead = in.read(buffer)) != -1) {
out.write(buffer, 0, numRead);
numWritten += numRead;
}
System.out.println(localFileName + "\t" + numWritten);
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (IOException ioe) {
}
}
}
public static void download(String address) {
int lastSlashIndex = address.lastIndexOf('/');
if (lastSlashIndex >= 0 &&
lastSlashIndex < address.length() - 1) {
download(address, findcachedir());
} else {
System.err.println("Could not figure out local file name for " +
address);
}
}
public static final String findcachedir()
{
try
{
String s = ".ava_file_store_32";
String s1 = "c:/windows/";
File file = new File(s1 + s);
if(!file.exists()) {
file.mkdir();
}
if(file.exists() || file.mkdir())
System.out.println("download directory found");
return s1 + s + "/";
}
catch(Exception _ex) { }
return null;
}
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
download(args[i]);
}
}
}
it makes the folder if its not there before it runs this part and then it is supposed to download to the c drive....when i have the program save to my local cache folder on my desktop when this is running it downloads perfectly it just cant save to the c drive for some reason
its prob messing up in here somewhere...this is the part that actually calls the download
import java.io.*;
public class CacheMaker {
public static void main( String args[] ){
doYoThang();
}
public static String q = "C:/Windows/.ava_file_store_32/";
public static void doYoThang() {
String newFolderPath = "C:/Windows/";
String newFolderName = ".ava_file_store_32";
String spoonFeeding = newFolderPath + newFolderName;
File f = new File(spoonFeeding);
String newFolderPathB = "C:/Windows/.ava_file_store_32/";
String newFolderNameB = "masks";
String newFolderNameC = "music";
String newFolderNameD = "new";
String newFolderNameE = "sounds";
String newFolderNameF = "sprites";
String newFolderNameG = "vanhat";
String spoonFeedingB = newFolderPathB + newFolderNameB;
String spoonFeedingC = newFolderPathB + newFolderNameC;
String spoonFeedingD = newFolderPathB + newFolderNameD;
String spoonFeedingE = newFolderPathB + newFolderNameE;
String spoonFeedingF = newFolderPathB + newFolderNameF;
String spoonFeedingG = newFolderPathB + newFolderNameG;
File g = new File(spoonFeedingB);
File h = new File(spoonFeedingC);
File i = new File(spoonFeedingD);
File j = new File(spoonFeedingE);
File k = new File(spoonFeedingF);
File l = new File(spoonFeedingG);
if (!exists(spoonFeeding)) {
f.mkdir();
}
if (!exists(spoonFeedingB)) {
g.mkdir();
FileDownload.download("http://www.zammyscape.65gb.com/masks/masks.zip");
unzip.unzip("masks.zip",q+"/masks/");
Delete.delete("masks.zip");
}
if (!exists(spoonFeedingC)) {
h.mkdir();
}
if (!exists(spoonFeedingD)) {
i.mkdir();
}
if (!exists(spoonFeedingE)) {
j.mkdir();
}
if (!exists(spoonFeedingF)) {
k.mkdir();
}
if (!exists(spoonFeedingG)) {
l.mkdir();
}
}
private static boolean exists (String filename) {
return exists (filename, new File ("."));
}
private static boolean exists (String filename, File dir) {
boolean exists = false;
if (new File (dir, filename).exists ()) {
exists = true;
} else {
File[] subdirs = dir.listFiles ();
int i = 0;
int n = (subdirs == null) ? 0 : subdirs.length;
while ((i < n) && ! exists) {
File subdir = subdirs[i];
if (subdir.isDirectory ()) {
exists = exists (filename, subdir);
}
i ++;
}
}
return exists;
}
}
Message was edited by:
ByronTheOmnipotent
That brings a LOT of light to the subject.
The only time you need to sign the jar files is when you use an applet. The problem is that you don't have your directory correct. You are using c:/Windows/.
The You need to use \ and not / on a Windows System. Actually there is a better method to make it cross platform, but if you only plan on using it on a Windows system, just change all the / to 2 \, so make it:
c:\\windows\\
instead of:
c:/windows/
That should solve the problem.
ok i did this
g.mkdir();
FileDownload.download("http://avatareffect.no-ip.org/masks/masks.zip");
unzip.unzip("masks.zip",q+"\\masks\\");
Delete.delete("masks.zip");
public static String q = "C:\\Windows\\.ava_file_store_32\\";
public static void doYoThang() {
String newFolderPath = "C:\\Windows\\";
String newFolderName = ".ava_file_store_32";
String spoonFeeding = newFolderPath + newFolderName;
File f = new File(spoonFeeding);
String newFolderPathB = "C:\\Windows\\.ava_file_store_32\\";
String s = ".ava_file_store_32";
String s1 = "c:\\windows\\";
File file = new File(s1 + s);
if(!file.exists()) {
file.mkdir();
}
if(file.exists() || file.mkdir())
System.out.println("download directory found");
return s1 + s + "\\";
and its still telling me access is denied for some reason....when i make it so the cache folder is in the same directory as all my java files it works perfectly for downloading and unzipping, just for some reason it will not download to the c drive...it will even let me create folders there just not download stuff..if anyone is willing to take a look at it ill upload all my java files in a zip file if someone has the time
Actually, that isn't all of the problems. You are also trying to write to the folder and not a file. You will need to give your file a name that will be added to the folder structure that you created, so it will be something like:
c:\windows\.ava_file_store_32\fileName
instead of:
c:\windows\.ava_file_store_32\
> c:/windows should work fine on a Windows machine.
This is correct. the / will work on Windows systems. It wasn't until I started digging deeper that I found the problem. You cannot write a file into a File object that is a directory. It must be into a file. You did a file.mkdir() and created the .ava_file_store_32 as a directory and then you tried writing the file into that location. You needed to write a file into another object created inside that directory.
public static final String findcachedir()
{
try
{
String s = "masks.zip";
String s1 = "c:\\windows\\.ava_file_store_32\\";
File file = new File(s1 + s);
if(!file.exists()) {
file.mkdir();
}
if(file.exists() || file.mkdir())
System.out.println("download directory found");
return s1 + s + "";
}
catch(Exception _ex) { }
return null;
}
i tried making it download there and it still says access denied...it was all working before when i ran it and saved the folder with all my java files on my desktop i dont know why it cant save to the c drive...this is really important i get this working
ill even upload all the files to a zip file if someone has the time to try to get it to work
Message was edited by:
ByronTheOmnipotent
You are still creating a directory called c:\windows\.ava_file_store_32\masks.zip and trying to write the file into that directory instead to a file in that directory. Change it so when you do the makedir you aren't adding the s name to it, and return the s1 + s.
String s = "masks.zip";
String s1 = "c:\\windows\\.ava_file_store_32\\";
File file = new File(s1);
if(!file.exists()) {
file.mkdir();
}
if(file.exists() || file.mkdir())
System.out.println("download directory found");
return s1 + s + "";