Results 1 to 7 of 7
Thread: Package Help
- 05-16-2011, 09:49 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 43
- Rep Power
- 0
Package Help
For a final project due tomorrow I am having issues packaging the search and sort program I have created...I don't know how to package it at all...any help would be greatly appreciated.
Java Code:/* * Daniel Marshall * Exam 2-Searching and Sorting * 04/08/2011 * CSCI 180 W02 * Prof. Jack Wu */ package classwork; import classwork.classwork; public class classwork {//creating class "classwork" public static void main(String[]args){//Main Method int list[]={123,157,162,217,345,612,718,913,319,412,123,159};//creating array int int i = binarySearch(list,2);System.out.println("The value of i is:" + i);//declaration of int i int j = binarySearch(list,11);System.out.println("The value of j is:" + j);//declaration of int j int k = binarySearch(list,12);System.out.println("The value of k is:" + k);//declaration of int j int l = binarySearch(list,1);System.out.println("The value of l:" + l);//declaration of int l int m = binarySearch(list,3);System.out.println("The value of m:" + m);//declaration of int m selectionsort(list); } public static int binarySearch (int[]list, int key){// int low = 0;int high = list.length - 1;//int low and high while(high > low){//while statement int mid = (low + high)/2;//int mid if (key < list[mid]) high = mid - 1;//if statement else if (key==list[mid])return mid;//else statement else low = mid + 1;//else statement } return - low -1;//return statement } public static void selectionsort(int[]list){ for (int i = list.length - 1;i>=1;i--){//for statement int currentmax = list[0];//int currentmax int currentmaxinx = 0; for (int j=1;j<=i;j++){//for loop if (currentmax == list[i])//if statement currentmax = list[j]; currentmaxinx = j; System.out.println(currentmax+" "+currentmaxinx);//System printout if(currentmaxinx!=i){//if statement list [currentmaxinx] = list[i]; list [i] = currentmax; } } } } } /* *Output *The value of i is:-1 The value of j is:-1 The value of k is:-1 The value of l:-1 The value of m:-1 123 1 162 2 217 3 345 4 612 5 718 6 913 7 319 8 412 9 123 10 Process completed. */
- 05-16-2011, 09:55 PM #2
What do you mean by "packaging"?
Putting the class files in a jar file?
Using the package statement?
- 05-17-2011, 01:43 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 43
- Rep Power
- 0
yes that is exactly what i mean
- 05-17-2011, 03:41 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,068
- Blog Entries
- 3
- Rep Power
- 15
Try this link and others on similar topics at this site, it should help: Creating a JAR File (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)
- 05-17-2011, 03:49 AM #5
Which of the two possibilities I listed is exactly what i mean?
- 05-17-2011, 04:18 AM #6
Member
- Join Date
- Mar 2011
- Posts
- 43
- Rep Power
- 0
- 05-17-2011, 04:22 AM #7it says it cannot find
If you use packages in your code, the class file in the jar file must be on the path set by the package statement. The jar command must get the files from the folder containing the classwork folder and include the classwork folder in the path to the class file that is added to the jar file.
Here's a batch file I use to create a jar file. The NormsTools folder is in the JavaDevelopment folder.
REM Make CreateTN.jar file - for 1.6
%DEV_DRIVE%
cd %DEV_HOME%\JavaDevelopment\Misc_Projects\CreateTN
jar -cmf CreateTN.mnf %JAVA_RUN%\CreateTN.jar CreateTN*.class
@REM Now pick up the Tools it needs:
cd %DEV_HOME%\JavaDevelopment\
jar -uf %JAVA_RUN%\CreateTN.jar NormsTools\AskMultipleChoices*.class NormsTools\*MakeEnterDoAction*.class NormsTools\NormsDropTarget*.class NormsTools\DroppedFileHandler*.class NormsTools\MyFilenameFilter*.class SlideShow\RSSUtility*.class SlideShow\ImageData*.class
@ECHO ---- Created: %JAVA_RUN%\CreateTN.jar ----
MORELast edited by Norm; 05-17-2011 at 04:28 AM.
Similar Threads
-
run package inside anthor package
By AhmedAdel in forum AWT / SwingReplies: 4Last Post: 04-20-2010, 12:52 PM -
What does package do?
By Mattedatten in forum New To JavaReplies: 2Last Post: 03-13-2010, 01:48 AM -
The declared package does not match the expected package
By oneforall in forum EclipseReplies: 7Last Post: 11-09-2009, 08:51 AM -
jxl package
By little_polarbear in forum New To JavaReplies: 5Last Post: 05-05-2009, 03:19 PM -
Regarding package
By makpandian in forum New To JavaReplies: 2Last Post: 03-24-2009, 06:47 PM
Bookmarks