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

  • Home
  • SEARCH
  • 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 8445373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:38:32+00:00 2026-06-10T09:38:32+00:00

I created a Java program, which reads a file, figures out which operation to

  • 0

I created a Java program, which reads a file, figures out which operation to perform ( create an object, call a class’ method) using the Reflection API in Java.
for example:

2234:org.powertac.common.Rate::9::new
2234:org.powertac.common.Rate::9::withValue::-0.5

if I find the new keyword, then I try to create a new object of that class. Otherwise, I will call the method (in the example, withValue()) with the argument -0.5.
The source code is shown below:

//
// program created a map between int and string
//
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
import java.lang.reflect.*;
import org.powertac.common.*;
import org.powertac.util.*;

public class Parser {

    private String filename;
    private Map< Integer, Object > map;
    //
    // just the default constructor is needed for now
    //
    public Parser(){
        this.map = new HashMap< Integer, Object >();
        this.filename = "/home/phillipe/powertac/powertac-server/" +
                        "server-distribution/log/powertac-boot.state";
    }
    //
    // override the default constructor
    //
    public Parser( String filename ){
        this.filename = filename;
    }

    public void parse() throws ClassNotFoundException{
        try{
            //
            // assure file exists before parsing
            //
            FileReader fr = new FileReader( this.filename );
            BufferedReader textReader = new BufferedReader( fr );
            String line;
            Integer id = 1;
            while(( line = textReader.readLine()) != null ){
                Pattern p = Pattern.compile("([^:]+):([^:]+)::([\\d]+)::([^:]+)::(.+)");
                Matcher m = p.matcher( line );
                if (m.find()) {
                  //String id = m.group(1);
                  String className = m.group(2);
                  int orderOfExecution = Integer.valueOf( m.group( 3 ));
                  String methodNameOrNew = m.group(4);
                  Object[] arguments = m.group(5).split("::");

                  if( methodNameOrNew.compareTo( "new" ) == 0 ){
                      System.out.println("Loading class: " + className);
                      Competition cc = null;


                      if( className.contains("Competition")){
                          this.map.put(id, cc);
                      }
                      else if( className.contains( "LocalBroker" )){
                          continue;
                      }
                      else {
                          Class<?> cl = Class.forName( className );
                          Constructor<?> cons = cl.getConstructor(String.class);
                          Object obj = cons.newInstance( arguments );
                          this.map.put( id , obj );
                      }

                  }
                  else{
                      Class<?> cl = Class.forName( className );
                      Method method = cl.getMethod( methodNameOrNew, String.class );
                      this.map.put(id, method);
                  }
                  id++;
                  System.out.printf("%s %s %d %s %d\n", id, className, orderOfExecution, methodNameOrNew, arguments.length);
                }
            }
            textReader.close();
        }
        catch( IOException ex ){
            ex.printStackTrace();
        }
        catch( ArrayIndexOutOfBoundsException ex){
            ex.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    public void print(){
        Iterator<?> iterator = this.map.keySet().iterator();  

        while (iterator.hasNext()) {  
           String key = iterator.next().toString();  
           String value = this.map.get(key).toString();  

           System.out.println(key + " " + value);  
        }  
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Parser parse = new Parser();
        try {
            parse.parse();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.exit( 0 );

    }

}

However, I’m getting the following error:

Loading class: org.powertac.common.Competition
2 org.powertac.common.Competition 0 new 1
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at Parser.parse(Parser.java:71)
    at Parser.main(Parser.java:123)
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

I loaded the .jar file which contained the class binaries. It’s my first time doing this kind of task in Java, so I’m not very familiar…. could someone please help me? Is it a missing library or something like?
THanks

  • 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-10T09:38:33+00:00Added an answer on June 10, 2026 at 9:38 am

    This class org.aspectj.lang.Signature is part of the Aspectj Runtime Library . If you’re using Maven you can add:

    <dependency>
        <groupId>aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.5.4</version>
    </dependency>
    

    to your POM.xml to retrieve the missing JAR files.

    or directly:

    aspectjrt-1.5.4.jar and also
    aspectjweaver-1.5.4.jar and log4j

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

Sidebar

Related Questions

I have created a little program that reads in a Java file and feeds
I created a Java program which sends an email from my gmail account. I
In a java program, I create a file with File temp = new File(temp);
I want to create registry key through java program to add the jar file
I'm trying to create a program that reads in a .txt file with multiple
I have created a small program which logs text data to a file on
I created a JAR file with my Java program. This piece of code will
I have problem with my Java program. How I read xml -file which has
I in the process of writting a simple java program which reads the contents
I have to refactor a Java program created with Eclipse RCP. My predecessor handed

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.