Solved

java ant project

Posted on 2014-07-31
12
598 Views
Last Modified: 2014-08-10
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
0
Comment
Question by:gudii9
  • 7
  • 4
12 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 40232049
The commands which you've just posted create a startable  jar file
0
 
LVL 7

Author Comment

by:gudii9
ID: 40236764
what is difference between startable jar and regular jar. why are they using startable jar in this example.

Please advise
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40236778
A startable jar is one that contains an application, which is startable by running the jar
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 7

Author Comment

by:gudii9
ID: 40237627
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
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 40237679
That IS step by step (or it wouldn't work)
0
 
LVL 7

Author Comment

by:gudii9
ID: 40242346
i will try all the steps.
0
 
LVL 7

Author Comment

by:gudii9
ID: 40252112
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
0
 
LVL 7

Author Comment

by:gudii9
ID: 40252138
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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40252154
You need to set the classpath properly for all the packages you're using
0
 
LVL 7

Author Comment

by:gudii9
ID: 40252158
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
0
 
LVL 7

Author Comment

by:gudii9
ID: 40252167
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
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question