Results 1 to 3 of 3
  1. #1
    naka is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Error: Could not find or load main class at one call and no error at another call in

    I am working on an implementation of ESA, I changed one of the java files, compiled it using the command

    Java Code:
    javac -cp lib/*:esalib.jar ./src/clldsystem/esa/ESAAnalyzer.java
    and pasted the .class file to the corresponding directory(esalib.jar/clldsystem/esa) in the .jar file. Also i changed the name the original corresponding .class file.

    Next, i have a python script which uses a command

    Java Code:
    java -cp lib/*:esalib.jar clldsystem.esa.ESAAnalyzer param1 param2
    but on running the python script, the command runs fine when used as:

    Java Code:
    x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer computer apple'
    args=shlex.split(x)
    p=subprocess.Popen(args)
    p.wait()
    But gives an Error: Could not find or load main class when used as:

    Java Code:
    x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer word1 word2'
    args=x.split()
    p=subprocess.Popen(args)
    p.wait()
    in the same script. I am reading the variables word1 and word2 from a file. Why would it work fine at one place and give an error at other? I have checked using print statements that i am reading from the file correctly, so that must not be an issue. Thanks

    here are the details of what happened:

    Java Code:
    nishant@nishant-Inspiron-1545:~/esalib$ python test.py
    ['java', '-cp', 'lib/*:esalib.jar', 'clldsystem.esa.ESAAnalyzer', 'bottle', 'apple']
    index loaded to memory
    compt
    appl
    vector 1 dimensions: 1782
    vector 2 dimensions: 2766
    0.024397644631615697
    beach
    ['people', 'sand', 'desert', 'snow']
    ['java', '-cp', '"lib/*:esalib.jar"', 'clldsystem.esa.ESAAnalyzer', 'word1', 'word2']
    Error: Could not find or load main class clldsystem.esa.ESAAnalyzer
    beach 
    people
    ['java', '-cp', '"lib/*:esalib.jar"', 'clldsystem.esa.ESAAnalyzer', 'word1', 'word2']
    Error: Could not find or load main class clldsystem.esa.ESAAnalyzer
    beach
    sand
    and so on for every iteration

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error: Could not find or load main class at one call and no error at another call

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    naka is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Re: Error: Could not find or load main class at one call and no error at another call

    I got it. This works:

    x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer %s %s' % (word1, word2)
    args=shlex.split(x)
    print args
    p=subprocess.Popen(args)
    p.wait()

Similar Threads

  1. Error:Could Not Find or Load Main Class
    By vickyv200 in forum New To Java
    Replies: 3
    Last Post: 08-29-2012, 01:10 AM
  2. Error: could not find or load main class
    By sloppygecko in forum New To Java
    Replies: 3
    Last Post: 08-08-2012, 03:11 PM
  3. Error: Could not find or load main class
    By Tybald in forum Eclipse
    Replies: 5
    Last Post: 05-28-2012, 11:22 AM
  4. Replies: 3
    Last Post: 12-09-2011, 03:51 AM
  5. Error: Could not find or load main class
    By ITSlave in forum New To Java
    Replies: 4
    Last Post: 09-15-2011, 09:47 AM

Tags for this Thread

Posting Permissions

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