debian - Yet another "Could not find or load main class package" Java error -


i have bunch of java source codes git repository: https://github.com/kevin-wayne/algs4/

i extracted ~/java. after extraction, .java files in ~/java/algs4-master/src/main/java/edu/princeton/cs/algs4. cd'd said directory , compiled binarysearch.java class following instructions inside source code itself: javac in.java stdin.java out.java stdout.java binarysearch.java, completed without error , produced 5 java .class files.

however, running java edu.princeton.cs.algs4.binarysearch fails error: not find or load main class edu.princeton.cs.algs4.binarysearch. i'm $classpath correct: /home/larssend/java/algs4-master/src/main/java/edu/princeton/cs/algs4

my system debian testing openjdk 8 headless.

what should run compiled class files?

this offending java source code, in case it's needed:

/******************************************************************************  *  compilation:  javac binarysearch.java  *  execution:    java binarysearch whitelist.txt < input.txt  *  dependencies: in.java stdin.java stdout.java  *  data files:   http://algs4.cs.princeton.edu/11model/tinyw.txt  *                http://algs4.cs.princeton.edu/11model/tinyt.txt  *                http://algs4.cs.princeton.edu/11model/largew.txt  *                http://algs4.cs.princeton.edu/11model/larget.txt  *  *  % java binarysearch tinyw.txt < tinyt.txt  *  50  *  99  *  13  *  *  % java binarysearch largew.txt < larget.txt | more  *  499569  *  984875  *  295754  *  207807  *  140925  *  161828  *  [367,966 total values]  *    ******************************************************************************/  package edu.princeton.cs.algs4;  import java.util.arrays;  /**  *  {@code binarysearch} class provides static method binary  *  searching integer in sorted array of integers.  *  <p>  *  <em>indexof</em> operations takes logarithmic time in worst case.  *  <p>  *  additional documentation, see <a href="http://algs4.cs.princeton.edu/11model">section 1.1</a> of  *  <i>algorithms, 4th edition</i> robert sedgewick , kevin wayne.  *  *  @author robert sedgewick  *  @author kevin wayne  */ public class binarysearch {      /**      * class should not instantiated.      */     private binarysearch() { }      /**      * returns index of specified key in specified array.      *      * @param  array of integers, must sorted in ascending order      * @param  key search key      * @return index of key in array {@code a} if present; {@code -1} otherwise      */     public static int indexof(int[] a, int key) {         int lo = 0;         int hi = a.length - 1;         while (lo <= hi) {             // key in a[lo..hi] or not present.             int mid = lo + (hi - lo) / 2;             if      (key < a[mid]) hi = mid - 1;             else if (key > a[mid]) lo = mid + 1;             else return mid;         }         return -1;     }      /**      * returns index of specified key in specified array.      * function poorly named because not give <em>rank</em>      * if array has duplicate keys or if key not in array.      *      * @param  key search key      * @param  array of integers, must sorted in ascending order      * @return index of key in array {@code a} if present; {@code -1} otherwise      * @deprecated replaced {@link #indexof(int[], int)}.      */     @deprecated     public static int rank(int key, int[] a) {         return indexof(a, key);     }      /**      * reads in sequence of integers whitelist file, specified      * command-line argument; reads in integers standard input;      * prints standard output integers <em>not</em> appear in file.      *      * @param args command-line arguments      */     public static void main(string[] args) {          // read integers file         in in = new in(args[0]);         int[] whitelist = in.readallints();          // sort array         arrays.sort(whitelist);          // read integer key standard input; print if not in whitelist         while (!stdin.isempty()) {             int key = stdin.readint();             if (binarysearch.indexof(whitelist, key) == -1)                 stdout.println(key);         }     } }  /******************************************************************************  *  copyright 2002-2016, robert sedgewick , kevin wayne.  *  *  file part of algs4.jar, accompanies textbook  *  *      algorithms, 4th edition robert sedgewick , kevin wayne,  *      addison-wesley professional, 2011, isbn 0-321-57351-x.  *      http://algs4.cs.princeton.edu  *  *  *  algs4.jar free software: can redistribute and/or modify  *  under terms of gnu general public license published  *  free software foundation, either version 3 of license, or  *  (at option) later version.  *  *  algs4.jar distributed in hope useful,  *  without warranty; without implied warranty of  *  merchantability or fitness particular purpose.  see  *  gnu general public license more details.  *  *  should have received copy of gnu general public license  *  along algs4.jar.  if not, see http://www.gnu.org/licenses.  ******************************************************************************/ 

when run

java edu.princeton.cs.algs4.binarysearch 

the jvm binarysearch class in edu.princeton.cs.algs4 package, maps edu/princeton/cs/algs4 starting directories in classpath. classpath should /home/larssend/java/algs4-master/src/main/java instead; way jvm find class in /home/larssend/java/algs4-master/src/main/java/edu/princeton/cs/algs4.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -