Solved

java ant project

Posted on 2014-07-31
12
601 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
How our DevOps Teams Maximize Uptime

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

 
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

Title # Comments Views Activity
spring jars download 1 35
maven module vs maven project 3 47
How to convert from xls to xlsx using java 7 55
ejb on wildfly 5 30
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

837 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