Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Error creating a Jar file in Java Project
Error creating a Jar file in Java Project [message #251967] Mon, 10 March 2008 14:06 Go to next message
Eclipse UserFriend
I updated Eclipse to the latest version.



If I should submit this error to different group please let me know
who/where.



When I go to create my jar file in a Java Project I do the following:



1) select the class from the Package Explorer.

2) I then select File > Export

3) I then select JAR file and press the Next button.

4) On the Jar Export window I check the following boxes only then
press next:

a) Export generated class files and resources

b) Export java source files and resources

c) JAR file: c:\copy_url_to_file.jar

d) Compress the contents of the JAR file

e) Overwrite existing files without warning

f) NOTE: When looking within the Select the resources to export
section y class is selected.

5) I do not have anything selected on the second screen “JAR
Packaging Options”

6) On the JAR Manifest Specification screen I have the following
selected:

a) Generate the manifest

b) Seal the JAR

7) When I click on Browse next to Main class: the screen is blank.
It do not find my class. When I created the below class I had Eclipse
generate the main method. I cannot get Eclipse to recognize any classes
with main methods in them for this or any Java Project. I do have Dynamic
Web Projects that I can do this process properly for. But it does not
work for Java Projects.



Any help is appreciated.





package edu.uiuc.webservices.http;



import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.net.URL;

import java.net.URLConnection;



public class CopyUrlToFile

{



/**

* @param args

*/

static public void main(String [ ] args)

{

if (args == null || args.length < 2 || args.length
> 2)

{

System.out.println("There must be two
parameters, URL and file name");

System.exit(1);

}

//

OutputStream os = null;

BufferedOutputStream bos = null;

InputStream is = null;

BufferedInputStream bis = null;

//

try

{

URL url = new URL(args[0].trim());

URLConnection urlConnection =
url.openConnection();

File file = new File(args[1].trim());

if (file.exists())

{

file.delete();

}

os = new FileOutputStream(file);

bos = new BufferedOutputStream(os);

is = urlConnection.getInputStream();

bis = new BufferedInputStream(is);

int data = 0;

while ((data = bis.read()) > -1)

{

bos.write(data);

}

}

catch (IOException e)

{

e.printStackTrace(System.out);

}

finally

{

try

{

bos.close();

os.close();

bis.close();

is.close();

}

catch (Exception e)

{


e.printStackTrace(System.out);

}

}

//

}

}







Lance Campbell

Project Manager/Software Architect

Web Services at Public Affairs

University of Illinois

217.333.0382

http://webservices.uiuc.edu
Re: Error creating a Jar file in Java Project [message #251971 is a reply to message #251967] Mon, 10 March 2008 14:42 Go to previous message
Eclipse UserFriend
Lance Campbell wrote:

Hi Lance. Any chance your class might have any compile warnings? I ran
into this the other day. If it does, you need to check "Export Class
with compile warnings" on the Packaging Options screen. Otherwise, it
skips the class but doesn't give you any message. Hope this helps. Mark

> I updated Eclipse to the latest version.
>
>
>
> If I should submit this error to different group please let me know
> who/where.
>
>
>
> When I go to create my jar file in a Java Project I do the following:
>
>
>
> 1) select the class from the Package Explorer.
>
> 2) I then select File > Export
>
> 3) I then select JAR file and press the Next button.
>
> 4) On the Jar Export window I check the following boxes only then
> press next:
>
> a) Export generated class files and resources
>
> b) Export java source files and resources
>
> c) JAR file: c:\copy_url_to_file.jar
>
> d) Compress the contents of the JAR file
>
> e) Overwrite existing files without warning
>
> f) NOTE: When looking within the Select the resources to export
> section y class is selected.
>
> 5) I do not have anything selected on the second screen �JAR
> Packaging Options�
>
> 6) On the JAR Manifest Specification screen I have the following
> selected:
>
> a) Generate the manifest
>
> b) Seal the JAR
>
> 7) When I click on Browse next to Main class: the screen is
> blank. It do not find my class. When I created the below class I had
> Eclipse generate the main method. I cannot get Eclipse to recognize any
> classes with main methods in them for this or any Java Project. I do
> have Dynamic Web Projects that I can do this process properly for. But
> it does not work for Java Projects.
>
>
>
> Any help is appreciated.
>
>
>
>
>
> package edu.uiuc.webservices.http;
>
>
>
> import java.io.BufferedInputStream;
>
> import java.io.BufferedOutputStream;
>
> import java.io.File;
>
> import java.io.FileOutputStream;
>
> import java.io.IOException;
>
> import java.io.InputStream;
>
> import java.io.OutputStream;
>
> import java.net.URL;
>
> import java.net.URLConnection;
>
>
>
> public class CopyUrlToFile
>
> {
>
>
>
> /**
>
> * @param args
>
> */
>
> static public void main(String [ ] args)
>
> {
>
> if (args == null || args.length < 2 || args.length
>> 2)
>
> {
>
> System.out.println("There must be two
> parameters, URL and file name");
>
> System.exit(1);
>
> }
>
> //
>
> OutputStream os = null;
>
> BufferedOutputStream bos = null;
>
> InputStream is = null;
>
> BufferedInputStream bis = null;
>
> //
>
> try
>
> {
>
> URL url = new URL(args[0].trim());
>
> URLConnection urlConnection =
> url.openConnection();
>
> File file = new File(args[1].trim());
>
> if (file.exists())
>
> {
>
> file.delete();
>
> }
>
> os = new FileOutputStream(file);
>
> bos = new BufferedOutputStream(os);
>
> is = urlConnection.getInputStream();
>
> bis = new BufferedInputStream(is);
>
> int data = 0;
>
> while ((data = bis.read()) > -1)
>
> {
>
> bos.write(data);
>
> }
>
> }
>
> catch (IOException e)
>
> {
>
> e.printStackTrace(System.out);
>
> }
>
> finally
>
> {
>
> try
>
> {
>
> bos.close();
>
> os.close();
>
> bis.close();
>
> is.close();
>
> }
>
> catch (Exception e)
>
> {
>
>
> e.printStackTrace(System.out);
>
> }
>
> }
>
> //
>
> }
>
> }
>
>
>
>
>
>
>
> Lance Campbell
>
> Project Manager/Software Architect
>
> Web Services at Public Affairs
>
> University of Illinois
>
> 217.333.0382
>
> http://webservices.uiuc.edu
>
>
>
>
Previous Topic:Rebuild after Restart
Next Topic:source refresh after running ant task
Goto Forum:
  


Current Time: Sun Apr 20 17:58:56 EDT 2025

Powered by FUDForum. Page generated in 0.03228 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top