Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

java ant project

Hi,

I am trying below example

http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html

I am not clear on what to do after compiling as below.

Creating a jar-file is not very difficult. But creating a startable jar-file needs more steps: create a manifest-file containing the start class, creating the target directory and archiving the files.

echo Main-Class: oata.HelloWorld>myManifest
md build\jar
jar cfm build\jar\HelloWorld.jar myManifest -C build\classes .
java -jar build\jar\HelloWorld.jar


like which jar i supposed to create etc?
please advise
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

The commands which you've just posted create a startable  jar file
Avatar of gudii9

ASKER

what is difference between startable jar and regular jar. why are they using startable jar in this example.

Please advise
A startable jar is one that contains an application, which is startable by running the jar
Avatar of gudii9

ASKER

I am not very clear on above link as the steps seems not detailed to me. Is there is any simple complete step by step example using eclipse. please advise
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

i will try all the steps.
Avatar of gudii9

ASKER

package jms;

import java.util.Properties;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;

public class ConsumerTwo {
	public ConsumerTwo() {
		try {
			Properties props = new Properties();
			props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
					"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
			props.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");
			Context context = new InitialContext(props);
			QueueConnectionFactory tcf = (QueueConnectionFactory) context
					.lookup("ConnectionFactory");
			QueueConnection conn = tcf.createQueueConnection();
			conn.start();
			QueueSession session = conn.createQueueSession(false,
					Session.CLIENT_ACKNOWLEDGE);
			Queue queue = (Queue) context.lookup("dynamicQueues/Movies");
			QueueReceiver reciever = session.createReceiver(queue);
			reciever.setMessageListener(new MyListener());
			conn.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new ConsumerTwo();
	}
}

Open in new window


I wrote one other consumer (ConsumerTwo) and ran in debug mode by putting breakpoint that is also reading on the same queue same old messages(after line 25 at line 26) as they were not deleted by old Consumer.java when i ran as java application, Please advise
Avatar of gudii9

ASKER

My example running fine from eclipse but when i run Producer.java from command prompt getting below errors.

C:\Users\ganesha\kepler_workspace\05122014_JMS\SpringJMSDemo\src\main\java\jms>
avac producer.java
producer.java:4: error: package javax.jms does not exist
import javax.jms.*;
^
producer.java:16: error: cannot find symbol
                        QueueConnectionFactory tcf = (QueueConnectionFactory) c
ntext
                        ^
  symbol:   class QueueConnectionFactory
  location: class Producer
producer.java:16: error: cannot find symbol
                        QueueConnectionFactory tcf = (QueueConnectionFactory) c
ntext
                                                      ^
  symbol:   class QueueConnectionFactory
  location: class Producer
producer.java:18: error: cannot find symbol
                        QueueConnection conn = tcf.createQueueConnection();
                        ^
  symbol:   class QueueConnection
  location: class Producer
producer.java:20: error: cannot find symbol
                        QueueSession session = conn.createQueueSession(false,
                        ^
  symbol:   class QueueSession
  location: class Producer
producer.java:21: error: cannot find symbol
                                        Session.CLIENT_ACKNOWLEDGE);
                                        ^
  symbol:   variable Session
  location: class Producer
producer.java:22: error: cannot find symbol
                        Queue queue = (Queue) context.lookup("dynamicQueues/Mov
es");
                        ^
  symbol:   class Queue
  location: class Producer
producer.java:22: error: cannot find symbol
                        Queue queue = (Queue) context.lookup("dynamicQueues/Mov
es");
                                       ^
  symbol:   class Queue
  location: class Producer
producer.java:23: error: cannot find symbol
                        QueueSender sender = session.createSender(queue);
                        ^
  symbol:   class QueueSender
  location: class Producer
producer.java:25: error: cannot find symbol
                        TextMessage msg1 = session.createTextMessage();
                        ^
  symbol:   class TextMessage
  location: class Producer
10 errors

C:\Users\ganesha\kepler_workspace\05122014_JMS\SpringJMSDemo\src\main\java\jms>


How to resolve them. Please advise
You need to set the classpath properly for all the packages you're using
Avatar of gudii9

ASKER

i am trying topic example by creating publisher in one instance of eclipse in workspace called XYZ
and subscriber on other isntance of eclipse in workapce called abc

so that when i publish some messages i want my subscrier automatically notified and get those messages.

workspace abc is not able to understand imports like
import javax.jms.* etc

I looked below url to get the jars
http://www.fluffycat.com/Java/JMS-With-A-Queue/

there are no jars. Any simple complete example on this with all needed jars on both queue, topic, point to point, pub-sub, durable-non durable topics using eclispe and apache mq. please advise
Avatar of gudii9

ASKER

when i run topic subscriver from flugycat link getting below error
http://www.fluffycat.com/Java/JMS-With-A-Topic/

Naming Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
Exception in thread "main" java.lang.NullPointerException
      at jmsTopic.WeasleyQuidditchTopicSubscriber.<init>(WeasleyQuidditchTopicSubscriber.java:53)
      at jmsTopic.WeasleyQuidditchTopicSubscriber.main(WeasleyQuidditchTopicSubscriber.java:17)



Please advise