Solved

java ant project

Posted on 2014-07-31
12
591 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
Comment Utility
The commands which you've just posted create a startable  jar file
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
Comment Utility
A startable jar is one that contains an application, which is startable by running the jar
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
Comment Utility
That IS step by step (or it wouldn't work)
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 7

Author Comment

by:gudii9
Comment Utility
i will try all the steps.
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
Comment Utility
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
Comment Utility
You need to set the classpath properly for all the packages you're using
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now