Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:44:16+00:00 2026-06-13T05:44:16+00:00

I wrote this Java hadoop program which will execute parallel indexation of files.The file

  • 0

I wrote this Java hadoop program which will execute parallel indexation of files.The file was created in eclipse

package org.myorg;

import java.io.*;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;

public class ParallelIndexation {


public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> { 
     private final static IntWritable zero = new IntWritable(0); 
     private Text word = new Text();
     public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { 
        String line = value.toString();
        int CountComputers;
        //DataInputStream ConfigFile = new DataInputStream( new FileInputStream("countcomputers.txt"));
        FileInputStream fstream = new FileInputStream("/usr/countcomputers.txt"); // путь к файлу
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String result = br.readLine(); // читаем как строку
        CountComputers = Integer.parseInt(result); // переводим строку в число
        //CountComputers=ConfigFile.readInt();
        in.close();
        fstream.close();
        ArrayList<String> paths = new ArrayList<String>();
        StringTokenizer tokenizer = new StringTokenizer(line, "\n");
        while (tokenizer.hasMoreTokens()) 
        {
          paths.add(tokenizer.nextToken());
        }
        String[] ConcatPaths= new String[CountComputers];
        int NumberOfElementConcatPaths=0;
        if (paths.size()%CountComputers==0)
        {
            for (int i=0; i<CountComputers; i++)
            {
                ConcatPaths[i]=paths.get(NumberOfElementConcatPaths);
                NumberOfElementConcatPaths+=paths.size()/CountComputers;
                for (int j=1; j<paths.size()/CountComputers; j++)
                {
                    ConcatPaths[i]+="\n"+paths.get(i*paths.size()/CountComputers+j);
                }
            }
        }
        else
        {
            NumberOfElementConcatPaths=0;
            for (int i=0; i<paths.size()%CountComputers; i++)
            {
                ConcatPaths[i]=paths.get(NumberOfElementConcatPaths);
                NumberOfElementConcatPaths+=paths.size()/CountComputers+1;              
                for (int j=1; j<paths.size()/CountComputers+1; j++)
                {
                    ConcatPaths[i]+="\n"+paths.get(i*(paths.size()/CountComputers+1)+j);
                }           
            }
            for (int k=paths.size()%CountComputers; k<CountComputers; k++)
            {
                ConcatPaths[k]=paths.get(NumberOfElementConcatPaths);
                NumberOfElementConcatPaths+=paths.size()/CountComputers;                
                for (int j=1; j<paths.size()/CountComputers; j++)
                {
                    ConcatPaths[k]+="\n"+paths.get((k-paths.size()%CountComputers)*paths.size()/CountComputers+paths.size()%CountComputers*(paths.size()/CountComputers+1)+j);
                }                   
            }
        }
        //CountComputers=ConfigFile.readInt();
        for (int i=0; i<ConcatPaths.length; i++)
        {
            word.set(ConcatPaths[i]);
            output.collect(word, zero);
        }
     }
}



public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, LongWritable> { 
    public native long Traveser(String Path);
    public native void Configure(String Path);
    public void reduce(Text key, <Iterator>IntWritable value, OutputCollector<Text, LongWritable> output, Reporter reporter) throws IOException { 
        long count;
        String line = key.toString();
        ArrayList<String> ProcessedPaths = new ArrayList<String>();
        StringTokenizer tokenizer = new StringTokenizer(line, "\n");
        while (tokenizer.hasMoreTokens()) 
        {
          ProcessedPaths.add(tokenizer.nextToken());
        }       
        Configure("/etc/nsindexer.conf");
        for (int i=0; i<ProcessedPaths.size(); i++)
        {
            count=Traveser(ProcessedPaths.get(i));
        }
        output.collect(key, new LongWritable(count));
      }
    static
    {
        System.loadLibrary("nativelib");
    } 
}

public static void main(String[] args) throws Exception { 
      JobConf conf = new JobConf(ParallelIndexation.class); 
      conf.setJobName("parallelindexation");
      conf.setOutputKeyClass(Text.class);
      conf.setOutputValueClass(LongWritable.class);
      conf.setMapperClass(Map.class);
      conf.setCombinerClass(Reduce.class);
      conf.setReducerClass(Reduce.class);
      conf.setInputFormat(TextInputFormat.class);
      conf.setOutputFormat(TextOutputFormat.class);
      FileInputFormat.setInputPaths(conf, new Path(args[0]));
      FileOutputFormat.setOutputPath(conf, new Path(args[1]));
      JobClient.runJob(conf);
  } 
}

I compiled the program by means of a command

javac -classpath /export/hadoop-1.0.1/hadoop-core-1.0.1.jar -d folder/classes folder/src/ParallelIndexation.java,
root@one:/export/hadoop-1.0.1/folder/classes# jar -cvf ParallelIndexation.jar -C /export/hadoop-1.0.1/folder/classes

Then for native methods I tried to create the .h file

root@one:/export/hadoop-1.0.1/folder/classes# javah -classpath /export/hadoop-1.0.1/hadoop-core-1.0.1.jar;/export/hadoop-1.0.1/folder/classes/ParallelIndexation.jar -jni org.myorg.ParallelIndexation

received the following mistake

Error: no classes specified
bash: /export/hadoop-1.0.1/folder/classes/ParallelIndexation.jar: Permission denied

thus on ParallelIndexation.jar the rights 0777 are set

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:44:18+00:00Added an answer on June 13, 2026 at 5:44 am
    1. You should use ‘:’ instead of ‘;’ when separating classpaths:

      javah -classpath /export/hadoop-1.0.1/hadoop-core-1.0.1.jar:/export/hadoop-1.0.1/folder/classes/ParallelIndexation.jar -jni org.myorg.ParallelIndexation
      
    2. Maybe you should check your jar structure.

    I tried to issue your commands with error 1 fixed and it worked.

    javac -cp /usr/share/hadoop/hadoop-core-1.0.4.jar org/myorg/ParallelIndexation.java
    jar c org/myorg/ParallelIndexation*.class > ParallelIndexation.jar
    javah -classpath /usr/share/hadoop/hadoop-core-1.0.4.jar:ParallelIndexation.jar -jni org.myorg.ParallelIndexation
    

    The problem is when you issued your version of the command:

    javah -classpath /export/hadoop-1.0.1/hadoop-core-1.0.1.jar;/export/hadoop-1.0.1/folder/classes/ParallelIndexation.jar -jni org.myorg.ParallelIndexation
    

    bash treated ‘;’ as a command separator, thus trying to execute two commands:

    javah -classpath /export/hadoop-1.0.1/hadoop-core-1.0.1.jar
    /export/hadoop-1.0.1/folder/classes/ParallelIndexation.jar -jni org.myorg.ParallelIndexation
    

    first command, ‘javah’ had no classes specified, second command was trying to execute ‘/export/hadoop-1.0.1/folder/classes/ParallelIndexation.jar’, but file is not executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this Java hadoop program which will execute parallel indexation of files.The file
I wrote this simple Java program which connects to internic server and returns the
I wrote this program in Java public class Why { public static void test()
I wrote this function which will attempt to store the map but its not
I am new to Java Multithreading World, I wrote this program, I just wanted
I wrote this short program to learn the javax.sound.midi system. This is using Java
I once wrote this line in a Java class. This compiled fine in Eclipse
I wrote this code for showing the HTML file ,which I have chosen it
i wrote this simple example: //file TestController.java public interface TestController { public List<Test> findAll();
I have a short question i have wrote this in java. Old code: class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.