Results 1 to 7 of 7

Thread: Package Help

  1. #1
    DMarsh12 is offline Member
    Join Date
    Mar 2011
    Posts
    43
    Rep Power
    0

    Default 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.
    */

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    What do you mean by "packaging"?
    Putting the class files in a jar file?
    Using the package statement?

  3. #3
    DMarsh12 is offline Member
    Join Date
    Mar 2011
    Posts
    43
    Rep Power
    0

    Default

    yes that is exactly what i mean

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Which of the two possibilities I listed is exactly what i mean?

  6. #6
    DMarsh12 is offline Member
    Join Date
    Mar 2011
    Posts
    43
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Which of the two possibilities I listed is exactly what i mean?
    using the package type... i am close to doing it but when i do package them together it says it cannot find the list in the other file i dont get it

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    it says it cannot find
    Please copy and paste the console showing the command entered and the error message.

    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 ----
    MORE
    Last edited by Norm; 05-17-2011 at 03:28 AM.

Similar Threads

  1. run package inside anthor package
    By AhmedAdel in forum AWT / Swing
    Replies: 4
    Last Post: 04-20-2010, 11:52 AM
  2. What does package do?
    By Mattedatten in forum New To Java
    Replies: 2
    Last Post: 03-13-2010, 12:48 AM
  3. Replies: 7
    Last Post: 11-09-2009, 07:51 AM
  4. jxl package
    By little_polarbear in forum New To Java
    Replies: 5
    Last Post: 05-05-2009, 02:19 PM
  5. Regarding package
    By makpandian in forum New To Java
    Replies: 2
    Last Post: 03-24-2009, 05:47 PM

Posting Permissions

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