Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Exception in thread "main" java.lang.NoSuchMethodException: VaccineCount.main([Ljava.lang.String;)

  1. #1
    Junior Member
    Join Date
    May 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Exception in thread "main" java.lang.NoSuchMethodException: VaccineCount.main([Ljava.lang.String;)

    import java.io.IOException;
    import java.util.StringTokenizer;

    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.io.IntWritable;
    import org.apache.hadoop.io.Text;
    import org.apache.hadoop.mapreduce.Job;
    import org.apache.hadoop.mapreduce.Mapper;
    import org.apache.hadoop.mapreduce.Reducer;
    import org.apache.hadoop.mapreduce.lib.input.FileInputFor mat;
    import org.apache.hadoop.mapreduce.lib.output.FileOutputF ormat;

    public class VaccineCount {

    public static class VaccineMapper extends Mapper<Object, Text, Text, IntWritable> {

    private Text state = new Text();
    private IntWritable vaccinatedCount = new IntWritable();

    public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
    String line = value.toString();

    if (!line.startsWith("Date") ) {


    String[] fields = value.toString().split(",");

    String stateName = fields[1];

    int lastColumnIndex = fields.length - 1;

    for (int i = 2; i < fields.length; i++) {
    if (fields[i].equalsIgnoreCase("Total Individuals Vaccinated")) {
    lastColumnIndex = i;
    break;

    }
    }
    int count = Integer.parseInt(fields[fields.length - 1]);

    state.set(stateName);
    vaccinatedCount.set(count);
    context.write(state, vaccinatedCount);

    }
    }

    public static class VaccineReducer extends Reducer<Text, IntWritable, Text, IntWritable> {

    private IntWritable totalVaccinatedCount = new IntWritable();

    public void reduce(Text key, Iterable<IntWritable> values, Context context)
    throws IOException, InterruptedException {
    int sum = 0;

    for (IntWritable count : values) {
    sum += count.get();
    }

    totalVaccinatedCount.set(sum);
    context.write(key, totalVaccinatedCount);
    }
    }

    public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    Job job = Job.getInstance(conf, "VaccineCount");
    job.setJarByClass(VaccineCount.class);
    job.setMapperClass(VaccineMapper.class);
    job.setReducerClass(VaccineReducer.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);
    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
    }

    }

    --- Update ---

    after running this Vaccine.jar file in hadoop linux it is displaying Exception in thread "main" java.lang.NoSuchMethodException: VaccineCount.main([Ljava.lang.String
    at java.base/java.lang.Class.getMethod(Class.java:2108)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:215)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136 )
    Last edited by Norm; May 20th, 2023 at 07:03 PM. Reason: Shortened title

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Exception in thread "main" java.lang.NoSuchMethodException: VaccineCount.main([Ljava.lang.String;) at java.base/java.lang.Class.getMethod(Class.java:2108) at org.apache.hadoop.util.RunJar.run(RunJar.java:215) at org.apache.hadoop.uti

    How are you executing the contents of the jar file?
    Have you tried opening a command prompt and entering the java command to execute the jar's contents:
    java -jar <JARFILE_NAME>
    What happens?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: August 16th, 2014, 01:34 AM
  2. Replies: 1
    Last Post: September 24th, 2013, 02:22 AM
  3. Replies: 2
    Last Post: July 2nd, 2013, 04:59 PM
  4. Replies: 8
    Last Post: August 9th, 2011, 08:25 PM
  5. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM