Not able to run jar file

Discussion in 'Java' started by Sheshagiri, Dec 16, 2012.

  1. Sheshagiri

    Sheshagiri

    Joined:
    Dec 16, 2012
    Messages:
    1
    Hi am new to Java..I am testing java code in below steps..

    1. ..Logger\Message.java files has below code..

    package logger;
    public class Message
    {
    public String GetFormattedMessage(String s)
    {
    return "Hello " + s;
    }
    }

    2. Another file ..Logger\LogMessage.java with below

    package logger;
    public class LogMessage
    {
    public static void main(String[] args)
    {
    Message m = new Message();

    String messageText = "";
    for(String s: args)
    {
    messageText += s;
    }
    System.out.println(m.GetFormattedMessage(messageText));
    }
    }

    3. Created directory "Classes" under Logger folder and compiled java files as below
    >javac -d "classes" Message.java
    >javac -d "classes" -classpath "classes" LogMessage.java
    4. Created manifest file (I may be failing here)
    \Logger\Manifest.txt

    "Main-Class: logger.LogMessage A B

    "
    4. Creating jar file as below (May failed here too..
    >jar cvfm logger.jar manifest.txt *.* (Dont know how to include only "Classes" folder in jar)
    5. When i ran >java -jar logger.jar i will get error as below
    "Error: Could not find or load main class logger.LogMessage A B"

    Without Jar file below code works fine ..
    >java -classpath "classes" logger.LogMessage A B
    output : Hello AB

    Please help in solving this problem or suggest corrected approach..
    Thanks in advance,
    Sheshagiri, Dec 16, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    564
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,714
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,748
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    653
    Arnold Peters
    Jan 5, 2005
  5. sed_y
    Replies:
    0
    Views:
    1,011
    sed_y
    Feb 15, 2012
Loading...

Share This Page