Runnable jar-File
I create a runnable jar-file. I don't have any problems creating my own Manifest, but my class-file uses a gif-file,too. And this gif-file will not be loaded out of the jar-file.
If I extract the gif-file out of the jar and put it in the same directory it works.
What have I to do?
Oliver
Wiesbaden, Germany
Oh no, I'm usin the gif only for an Icon in a JFrame. So I try to load it in the constructor of the JFrame. Like this:
Toolkit kit = Toolkit.getDefaultToolkit();
Image icon = kit.getImage("FrameIcon.gif");
setIconImage(icon);
Then I wrote my own manifest and put the *.class and the gif-File in a runnable jar. But now there is no icon in the JFrame. So I put the gif in the same directory as the jar and now the icon is shown.
Why can't I put the icon in the jar-file, too.
Similar Messages
-
I recently started working with Java 8. I have been doing Java development on and off since the early 1990's. Most recently I have been doing all my current work in Java 6. I decided to "take the plunge" and to start getting involved with Java 8. I have an imaging application for geologic research I started working on in Java 6 and Swing, and I am now continuing that development under Java 8. It was a pleasant surprise that to find that all of my code built without any changes (I'm using Eclipse Luna and just deleted the Java 6 runtime and added the Java 8 runtime after downloading it). The application launches fine from inside Eclipse.
However I ran into a problem when exporting the application from Eclipse to a runnable JAR file and then trying to launch it. After creating the runnable JAR I was not able to launch it by simply double clicking. A command line box would open for a second, then close and the application window would never open. To upgrade from Java 6 to Java 8 I only downloaded the Java 8 runtime environment, not the Java 8 JDK. I am working in Windows 7 and tried updating the JAR file associations and experimented with various path entries in my environment variables. No mater what I did I could not simply double click the runnable JAR to launch it.
Then I deleted all my Java downloads and started over. This time all I did was downloaded the Java 8 JDK and installed it. I then pointed Eclipse to the Java 8 runtime environment that was installed with the Java 8 JDK. My code built and executed perfectly in the Eclipse environment. Then I exported the the Eclipse project as a runnable JAR again and tried to launch it. This time it worked as expected. Double clicking the runnable JAR launched the application!
So my question is if I want to give this application to someone to run (i.e. deploy it) that is not a developer, do I have to have them install the Java 8 JDK? I assumed that all someone would need to run the application as a runnable JAR is the Java 8 runtime environment, not the JDK. However, when I had only the Java 8 runtime environment installed I could not launch the runnable JAR. With the Java 8 JDK I was able to run the runnable JAR as expected, with no problem.
Am I missing something?
Thanks,
MikeI found an answer to my own questions.
I'm posting what I found to answer my questions so that anyone with a similar question looking here will have an answer.
The following Oracle link appears to explain everything about deployment that a developer needs to know!
http://docs.oracle.com/javase/8/docs/technotes/guides/deploy/
Mike -
How to run a jar file in a browswer?
Hi, everyone:
I got a problem here. I would like to run my jar file in a html-based brower, should I write another applet for my jar file? How can I do that? (I don't have applet in my jar file, but only JFrame) Is there any way I can put a runnable jar file into an applet and show on the brower? Could anyone show me how to write this code? Thank you very much!!
-jxchouAt first you need a java plug-in for your browser.
Next you have to implement an applet in your jar-file.
The tag in your html-document should look like:
<applet code="Sample.class" archive="sample.jar" width="400" height="400"></applet> -
Problems with CLASSPATH in a executable jar file
Hi there
I'm having a problem that I don't know how to solve. My generalq uestion is:
"Why isn't my CLASSPATH (java.class.path) forwarded into ar unnable class inside a jar file?"
The situation is:
I have made a runnable jar file containing an ant build.xml file, a jar file containing some patch files, and a class called AntLoader.class. AntLoader are the file that are executed (inserted into the manifest). This works. The class are executed, but it can't find the package needed for starting ant.
ant.jar is in my CLASSPATH, and therefore everything works fine if I'm running AntLoader outside the jar file.
I know that I can use different ClassLoader classes for dynamicly loading of a class, but then I need a path to where ant.jar is located. And then again my system wont be general. The jar file is supposed to be distributed as a system patch to customers. And their location of where ant is installed will not be the same.
So what I'm looking for is a way to pass my CLASSPATH from my environment on to a jar file. Is that possible?
running java -classpath "${CLASSPATH}" -jar cpc.jar doesn't help at all. The java.class.path is still set to cpc.jar when I'm executing the AntLoader class inside cpc.jar.
Can anyone please help me?
Brgds
Jakob've found the solution to the problem. You have to use the -Xbootclasspath/a parameter when running java.
Example on unix:
java -Xbootclasspath/a:${CLASSPATH} -jar test.jar
Brgds
Jakob -
Hi,
I'm trying to make a runnable JAR in Eclipse, but I don't know how to limit which libraries or other source codes to be included inside. Does anyone know how to do this? The JAR I'm making is 13.6 MB, much bigger than I think it should be.
Thanks.You can create a runnable jar file only when u have a public class with main method as a entry point of java Application.Always create runnable jar file when u r using GUI in ur java application.
Steps which r required in Eclipse for creating runnable jar file as herein after provided
1-Right click on your project and select export option.A export window will get pop-up.
2-Select jar file option from the poped-up window which will be in java option of window.
3-After Clicking JarFile option a new window will get pop-up.
4-Select the export destination for ur jar file and click next.
5-After clicking the next a new screen you will see, click on next button again.
6-Now u will see a new screen which has a field name as "Main Class" browse for your main class of appliaction.main class is once which has main method.
7-Now select finish.
U hav done..
now double click on your created jar n u will see the output.....
if u hav any other problem...than let me know
Regards,
Ashvani Kumar -
Trying to create runnable .rar-file
I'm trying to create a runnable .jar-file of my application.
I've got two classes, StealthServer and ClientThread. StealthServer cointains the main method. I've joined these classes in a .jar-file as Demo.jar. I made a manifest-file like this:
Main-Class: StealthServerI joined the manifest-file with Demo.jar like this:
jar cmf manifest.txt start.jar Demo.jarThe I tried to run start.jar like this:
java -jar start.jarThat leaves me with this:
Exception in thread "main" java.lang.NoClassDefFoundError: StealthServerCan anyone tell me what I'm doing wrong?This is what I got when I tried it your way ChuckBing.
C:\Shared\Demo\bytecode>java -jar Demo.jar
Exception in thread "main" java.lang.ClassFormatError: Incompatible
1347093252 in class file StealthServer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Sourc
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)What is wrong now? -
Can't open .jar file? (I have Lion)
I have written a program in Eclipse, and I exported it as a runnable jar to my desktop. But when I go and click on it I get this message:
The Java Jar file "Four Room Game.jar" could not be launched
check the console for possible error messages
what is wrong with it and how can I fix it?Izeki3l wrote:
It says I have Java 7
Were you able to turn logging on, try the .jar again and then read the log?
I know nothing about Eclipse, but I do know there are many applications and web sites that are not Java 7 compatible. You will probably have to check with the developer and find out if Eclipse is and if an update is available or in the works. You will most probably need to have information from the Java log to submit to the developer. -
Loading an image into an Applet from a JAR file
Hello everyone, hopefully a simple question for someone to help me with!
Im trying to load some images into an applet, currently it uses the JApplet.getImage(url) method just before registering with a media tracker, which works but for the sake of efficiency I would prefer the images all to be contained in the jar file as oppossed to being loaded individually from the server.
Say I have a class in a package eg, 'com.mydomain.myapplet.class.bin' and an images contained in the file structure 'com.mydomain.myapplet.images.img.gif' how do I load it (and waiting for it to be loaded before preceeding?
I've seen lots of info of the web for this but much of it is very old (pre 2000) and im sure things have changed a little since then.
Thanks for any help!I don't touch applets, so I can't help you there, but here's some Friday Fun: tracking image loading.
import java.awt.*;
import java.awt.image.*;
import java.beans.*;
import java.io.*;
import java.net.*;
import javax.imageio.*;
import javax.imageio.event.*;
import javax.imageio.stream.*;
import javax.swing.*;
public class ImageLoader extends SwingWorker<BufferedImage, Void> {
private URL url;
private JLabel target;
private IIOReadProgressAdapter listener = new IIOReadProgressAdapter() {
@Override public void imageProgress(ImageReader source, float percentageDone) {
setProgress((int)percentageDone);
@Override public void imageComplete(ImageReader source) {
setProgress(100);
public ImageLoader(URL url, JLabel target) {
this.url = url;
this.target = target;
@Override protected BufferedImage doInBackground() throws IOException {
ImageInputStream input = ImageIO.createImageInputStream(url.openStream());
try {
ImageReader reader = ImageIO.getImageReaders(input).next();
reader.addIIOReadProgressListener(listener);
reader.setInput(input);
return reader.read(0);
} finally {
input.close();
@Override protected void done() {
try {
target.setIcon(new ImageIcon(get()));
} catch(Exception e) {
JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
//demo
public static void main(String[] args) throws IOException {
final URL url = new URL("http://blogs.sun.com/jag/resource/JagHeadshot.jpg");
EventQueue.invokeLater(new Runnable(){
public void run() {
launch(url);
static void launch(URL url) {
JLabel imageLabel = new JLabel();
final JProgressBar progress = new JProgressBar();
progress.setBorderPainted(true);
progress.setStringPainted(true);
JScrollPane scroller = new JScrollPane(imageLabel);
scroller.setPreferredSize(new Dimension(800,600));
JPanel content = new JPanel(new BorderLayout());
content.add(scroller, BorderLayout.CENTER);
content.add(progress, BorderLayout.SOUTH);
JFrame f = new JFrame("ImageLoader");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setContentPane(content);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
ImageLoader loader = new ImageLoader(url, imageLabel);
loader.addPropertyChangeListener( new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if ("progress".equals(evt.getPropertyName())) {
progress.setValue((Integer)evt.getNewValue());
System.out.println(evt.getNewValue());
} else if ("state".equals(evt.getPropertyName())) {
if (SwingWorker.StateValue.DONE == evt.getNewValue()) {
progress.setIndeterminate(true);
loader.execute();
abstract class IIOReadProgressAdapter implements IIOReadProgressListener {
@Override public void imageComplete(ImageReader source) {}
@Override public void imageProgress(ImageReader source, float percentageDone) {}
@Override public void imageStarted(ImageReader source, int imageIndex) {}
@Override public void readAborted(ImageReader source) {}
@Override public void sequenceComplete(ImageReader source) {}
@Override public void sequenceStarted(ImageReader source, int minIndex) {}
@Override public void thumbnailComplete(ImageReader source) {}
@Override public void thumbnailProgress(ImageReader source, float percentageDone) {}
@Override public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {}
} -
Jar file could not find main class.. I cant see why?
I have read loads of tutorials on this and it should be very straight forward but i STILL cant make a working jar file of my program.. please see if you can see anything wrong with what im doing..
my program is one .java file that compiles perfectly, and is runnable both through eclipse and by using the command prompt.. i made a jar file using both eclipse and the command prompt, and neither worked.. every time i run it by double clicking it i get the error "could not find main class, program will exit". here is the contents of my jar:
CorePackage\IPEmailer.class
CorePackage\IPEmailer$1.class
CorePackage\IPEmailer$SMTPAuthenticator.class
META-INF\MANIFEST.MF
the MANIFEST.MF file contains:
Manifest-Version: 1.0
Class-path: .
Created-By: 1.6.0_02 (Sun Microsystems Inc.)
Main-Class: CorePackage.IPEmailer
(yes there is a blank line at the end)
the class mentioned in 'Main-Class' has a main method that looks like this:
public static void main(String[] args) {
// TODO Auto-generated method stub
new IPEmailer();
}the program uses 2 external jar files:
activation.jar
mail.jar
and reads a file called:
ipemailer.ini
and writes a file called:
ip.txt
the program has no GUI and is intended to run 'silently' in the background
please help me understand what is wrong with thispackage CorePackage;
import javax.mail.*;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class IPEmailer implements Runnable{
* @param args
String recipientsinput[]={""};
String subject;
String body;
String server;
String user;
String pass;
String from;
String urlString = "http://www.whatismyip.org";
String currentIP;
String ipFromFile;
boolean webFailed;
long interval = 900000; //15 mins
long oldInterval;
Thread t = new Thread(this);
public static void main(String[] args) {
// TODO Auto-generated method stub
new IPEmailer();
public IPEmailer(){
..........etccould the problem be that the class is a thread? i cant see why it would be, but ive never made a jar where the main class also 'implements runnable' -
How to include jar files in ant script for compiling
i am trying to manually include j2ee.jar for compiling, here is the entire build.xml:
<?xml version="1.0"?>
<!--PRIMARY build file for all of dev modual -->
<project name="com" default="compile.all" basedir="../">
<path id="project.class.path">
<pathelement location="lib/"/>
<pathelement path="${java.class.path}/"/>
<pathelement path="${additional.path}"/>
<pathelement path="${CLASSPATH}" />
<pathelement path="${classpath}" />
</path>
<property name="SRCDIR" value="${basedir}/java" />
<property name="DSTDIR" value="${basedir}/classes" />
<property name="LIBDIR" value="${basedir}/libs" />
<property name="JARDIR" value="${basedir}/jars" />
<property name="DOCDIR" value="${basedir}/docs" />
<property name="ORACLE.JAR" value="${LIBDIR}/orcl/8.1.7/classes12.zip" />
<property name="JUNIT.JAR" value="${LIBDIR}/junit/3.7/junit.jar" />
<property name="CLASSPATH" value="z:/tools/java;${SRCDIR};${DSTDIR};${JUNIT.JAR};${ORACLE.JAR}" />
<property name="POLICYFILE" value="${SRCDIR}/com/leader/cti/main/ctimain.policy" />
<property name="DEBUG_FLAG" value="on" />
<property name="OPTIMIZE_FLAG" value="off" />
<property name="DEPRECATION_FLAG" value="off" />
<property name="RMI_VERSION" value="1.2" />
<!-- builds everything -->
<target name="compile.all">
<antcall target="compile.cti"/>
</target>
<target name="compile.vbsf" description="Compiles files for vbsf.jar.">
<mkdir dir="${DSTDIR}"/>
<copy file="${SRCDIR}/VBSFELK5UD3SWQ2E.class" todir="${DSTDIR}"/>
<javac srcdir="${SRCDIR}" destdir="${DSTDIR}" classpath="${CLASSPATH}" debug="${DEBUG_FLAG}" deprecation="${DEPRECATION_FLAG}" optimize="${OPTIMIZE_FLAG}" >
<include name="com/objectmatter/**/*.java" />
</javac>
</target>
<target name="compile.persist" description="Compiles files for persist.jar." depends="compile.vbsf" >
<javac srcdir="${SRCDIR}" destdir="${DSTDIR}" debug="${DEBUG_FLAG}" deprecation="${DEPRECATION_FLAG}" optimize="${OPTIMIZE_FLAG}" >
<classpath refid="project.class.path"/>
<include name="com/leader/persist/**/*.java" />
<include name="testcom/leader/persist/**/*.java" />
</javac>
</target>
<target name="compile.cti" description="Compiles files for both cti jars." depends="compile.persist,compile.cti.only" />
<target name="compile.cti.only" description="Compiles files for both cti jars." >
<javac srcdir="${SRCDIR}" destdir="${DSTDIR}" debug="${DEBUG_FLAG}" deprecation="${DEPRECATION_FLAG}" optimize="${OPTIMIZE_FLAG}" >
<classpath refid="project.class.path"/>
<include name="com/leader/cti/**/*.java" />
<include name="testcom/leader/cti/**/*.java" />
</javac>
<rmic classpath="${CLASSPATH}" base="${DSTDIR}" stubversion="${RMI_VERSION}" >
<include name="com/leader/cti/main/RMICTIService.class" />
<include name="com/leader/cti/main/RMIConferenceCall.class" />
<include name="com/leader/cti/main/RMIConferenceCallReservation.class" />
<include name="com/leader/cti/main/FakeRmiCtiService.class" />
<include name="com/leader/cti/main/FakeRmiConferenceCall.class" />
<!--include name="com/leader/cti/main/DerivedQueueReceiver.class"/-->
</rmic>
</target>
<!-- build all dev jars -->
<target name="jar.all"
description="Create all jar files"
depends="jar.vbsf, jar.persist, jar.jeti, jar.service"/>
<!-- build vbsf.jar -->
<target name="jar.vbsf"
description="Create client distribution jar for vbsf code"
depends="compile.vbsf" >
<mkdir dir="${JARDIR}" />
<jar jarfile="${JARDIR}/vbsf.jar"
basedir="${DSTDIR}" >
<include name="VBSFELK5UD3SWQ2E.class"/>
<include name="com/objectmatter/**/*.class" />
</jar>
</target>
<!-- build persist.jar -->
<target name="jar.persist"
description="Create client distribution jar"
depends="compile.vbsf,compile.persist" >
<mkdir dir="${JARDIR}" />
<jar jarfile="${JARDIR}/persist.jar"
basedir="${DSTDIR}" >
<include name="com/leader/persist/**/*.class" />
</jar>
</target>
<!-- build jeti.jar -->
<target name="jar.jeti"
description="Create client distribution jar"
depends="compile.vbsf,compile.persist,compile.cti" >
<mkdir dir="${JARDIR}" />
<jar jarfile="${JARDIR}/jeti.jar"
basedir="${DSTDIR}" >
<include name="com/leader/cti/rmiint/*" />
<include name="com/leader/cti/main/*Stub*" />
<include name="com/leader/cti/util/**" />
<include name="com/leader/cti/vru/*" />
<include name="com/leader/cti/interfaces/*" />
<include name="com/leader/cti/history/*" />
<include name="com/leader/cti/autodial/*" />
</jar>
</target>
<!-- build jeti_service.jar -->
<target name="jar.service"
description="Create the jar file for the service"
depends="compile.vbsf,compile.persist,compile.cti" >
<mkdir dir="${JARDIR}" />
<copy file="${basedir}/vbsf/cti.schema" tofile="${DSTDIR}/cti.schema" />
<copy file="${basedir}/vbsf/cti.schema" tofile="/tools/java/com/leader/osapplication/persist/cti.schema" />
<jar jarfile="${JARDIR}/jeti_service.jar"
basedir="${DSTDIR}" >
<include name="com/leader/cti/**" />
<include name="cti.schema" />
</jar>
</target>
<!-- build jeti.jar, jeti_service.jar -->
<target name="jar.cti"
description ="Create client/server jars for cti"
depends="jar.jeti,jar.service" />
<!-- clean everything. -->
<target name="clean">
<delete dir="${DSTDIR}" />
<delete dir="${JARDIR}" />
<delete dir="${DOCDIR}" />
</target>
<target name="clean.cti" description="clean cti class files (not jars)">
<delete dir="${DSTDIR}/com/leader/cti" />
<delete dir="${DSTDIR}/testcom/leader/cti" />
</target>
<!-- Run the gui CTI tests -->
<target name="test_cti_gui">
<java classname="junit.swingui.TestRunner" classpath="${CLASSPATH}" fork="yes">
<arg value="testcom.leader.cti.CTIPackageTest"/>
<sysproperty key="leader.unique_number_generator.file" value="unique_number_generator_file_test" />
<sysproperty key="vbsf.repository" value="/tools/java/dev/vbsf" />
<sysproperty key="vbsf.enableGlobalCaching" value="false" />
</java>
</target>
<target name="test.cti.gui"
depends="test_cti_gui" />
<!-- Run the text version of CTI tests -->
<target name="test">
<java classname="junit.textui.TestRunner" classpath="${CLASSPATH}" fork="yes">
<arg value="testcom.leader.cti.CTIPackageTest"/>
<sysproperty key="leader.unique_number_generator.file" value="unique_number_generator_file_test" />
</java>
</target>
<!-- Run CTI service -->
<target name="run.service"
description="run the service normally"
depends="compile.all" >
<java classname="com.leader.cti.main.CTIMain"
classpath="${CLASSPATH}"
fork="yes" >
<sysproperty key="java.security.policy"
file="${POLICYFILE}" />
<sysproperty key="config.dir"
value="${SRCDIR}/com/leader/cti/main/" />
</java>
</target>
<!-- Run fake CTI service -->
<target name="run.service.fake"
description="run the fake service"
depends="compile.all" >
<java classname="com.leader.cti.main.FakeCtiMain"
classpath="${CLASSPATH}"
fork="yes" >
<sysproperty key="java.security.policy"
file="${POLICYFILE}" />
<sysproperty key="config.dir"
value="${SRCDIR}/com/leader/cti/main/" />
</java>
</target>
<!-- Run CTI service emulator -->
<target name="run.service.emulator"
description="run the service normally"
depends="compile.all" >
<java classname="com.leader.cti.main.CTIMain"
classpath="${CLASSPATH}"
fork="yes" >
<sysproperty key="java.security.policy"
file="${POLICYFILE}" />
<sysproperty key="config.dir"
value="${SRCDIR}/com/leader/cti/main/" />
<sysproperty key="vru.propertyfile"
value="emulator.properties" />
</java>
</target>
<!-- Runs the CTI service and emulator -->
<target name="run.emulator"
description="run the service and the emulator"
depends="compile.all" >
<java classname="testcom.leader.cti.vru.emulator.VRUEmulator"
classpath="${CLASSPATH}"
fork="yes" />
</target>
<!-- Runs the gui CONCALL testss -->
<target name="run.gui"
description="run the concall test gui"
depends="compile.all" >
<java classname="testcom.leader.cti.main.SwingClient"
classpath="${CLASSPATH}"
fork="yes" >
<sysproperty key="java.security.policy"
file="${POLICYFILE}" />
</java>
</target>
<!-- Fires the maptool up. Defaults to CTI`s Schema file. -->
<target name="maptool" >
<java classname="com.objectmatter.bsf.mapping.toolgui.MapTool"
fork="yes"
classpath="${CLASSPATH}" >
<sysproperty key="vbsf.repository" value="${basedir}/vbsf" />
</java>
</target>
<target name="javadoc_cti">
<mkdir dir="${basedir}/docs"/>
<javadoc packagenames="com.leader.*" classpath="${CLASSPATH}" sourcepath="${SRCDIR}" destdir="${DOCDIR}\cti" author="true" version="true" use="true" windowtitle="Leader CTI API" doctitle="Leader Technologies, Inc" bottom="Copyright © 2005 Leader Technologies Incorporated.<BR>All Rights Reserved." maxmemory="128m">
<group title="Leader CTI Packages" packages="com.leader*"/>
</javadoc>
</target>
<target name="javadoc_vbsf">
<mkdir dir="${basedir}/docs"/>
<javadoc packagenames="com.objectmatter.* " classpath="${CLASSPATH}" sourcepath="${SRCDIR}" destdir="${DOCDIR}" author="true" version="true" use="true" windowtitle="VBSF by ObjectMatter API" doctitle="Leader Technologie, Inc" bottom="Copyright © 2005 Leader Technologies Incorporated.<BR>All Rights Reserved." maxmemory="128m">
<group title="Objectivity Packages" packages="com.objectmatter.*"/>
</javadoc>
</target>
</project>
i am getting this:
compile.all:
compile.vbsf:
compile.persist:
compile.cti.only:
Compiling 1 source file to C:\Projects\Leader\dev\classes
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:14: package javax.jms does not exist
import javax.jms.*;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:17: package javax.jms does not exist
import javax.jms.Queue;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:18: package javax.jms does not exist
import javax.jms.JMSException;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:19: package javax.jms does not exist
import javax.jms.Message;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:28: cannot find symbol
symbol: class MessageListener
public abstract class BasicMQReceiverAsyncR implements Runnable, MessageListener
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:44: cannot find symbol
symbol : class QueueConnectionFactory
location: class BasicMQReceiverAsyncR
QueueConnectionFactory queueConnectionFactory = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:45: cannot find symbol
symbol : class QueueConnection
location: class BasicMQReceiverAsyncR
QueueConnection queueConnection = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:46: cannot find symbol
symbol : class QueueSession
location: class BasicMQReceiverAsyncR
QueueSession queueSession = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:48: cannot find symbol
symbol : class QueueReceiver
location: class BasicMQReceiverAsyncR
QueueReceiver queueReceiver = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:49: cannot find symbol
symbol : class TextMessage
location: class BasicMQReceiverAsyncR
TextMessage message = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:406: cannot find symbol
symbol : class QueueConnectionFactory
location: class BasicMQReceiverAsyncR
queueConnectionFactory = (QueueConnectionFactory)
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:408: package javax.jms does not exist
queue = (javax.jms.Queue) jndiContext.lookup(QUEUE_NAME); //queue1 = (javax.jms.Queue)jndiContext.lookup("MyQueue1");
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:433: cannot find symbol
symbol : variable Session
location: class BasicMQReceiverAsyncR
Session.AUTO_ACKNOWLEDGE);
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:447: cannot find symbol
symbol : class JMSException
location: class BasicMQReceiverAsyncR
catch (JMSException e)
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:461: cannot find symbol
symbol : class JMSException
location: class BasicMQReceiverAsyncR
catch (JMSException x)
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:482: cannot find symbol
symbol : class BytesMessage
location: class BasicMQReceiverAsyncR
if (m instanceof BytesMessage)
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:488: cannot find symbol
symbol : class BytesMessage
location: class BasicMQReceiverAsyncR
BytesMessage bytesMsg = (BytesMessage)m;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:488: cannot find symbol
symbol : class BytesMessage
location: class BasicMQReceiverAsyncR
BytesMessage bytesMsg = (BytesMessage)m;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:501: cannot find symbol
symbol : class QueueSession
location: class BasicMQReceiverAsyncR
QueueSession queueSession2 = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:502: cannot find symbol
symbol : class QueueSender
location: class BasicMQReceiverAsyncR
QueueSender queueSender2 = null;
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:510: cannot find symbol
symbol : variable Session
location: class BasicMQReceiverAsyncR
Session.AUTO_ACKNOWLEDGE);
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:514: cannot find symbol
symbol : class BytesMessage
location: class BasicMQReceiverAsyncR
BytesMessage bytesMessage = queueSession.createBytesMessage();
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:523: cannot find symbol
symbol : variable DeliveryMode
location: class BasicMQReceiverAsyncR
DeliveryMode.PERSISTENT,
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:524: cannot find symbol
symbol : variable DEFAULT_PRIORITY
location: class com.leader.cti.vru.Message
Message.DEFAULT_PRIORITY,
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:525: cannot find symbol
symbol : variable DEFAULT_TIME_TO_LIVE
location: class com.leader.cti.vru.Message
Message.DEFAULT_TIME_TO_LIVE);
C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:529: cannot find symbol
symbol : class JMSException
location: class BasicMQReceiverAsyncR
catch (JMSException x)
26 errors
C:\Projects\Leader\dev\java\build.xml:34: The following error occurred while executing this line:
C:\Projects\Leader\dev\java\build.xml:56: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 8 seconds)
my class path is:
.;C:\Projects\Leader\prototype\jms\build\classes;C:\Projects\Leader\dev\libs\persist.jar;C:\Projects\Leader\dev\classes;%OPENJMS_HOME%\lib;%OPENJMS_HOME%\lib\antlr-2.7.2.jar;%OPENJMS_HOME%\lib\castor-0.9.5.jar;%OPENJMS_HOME%\lib\commons-codec-1.3.jar;%OPENJMS_HOME%\lib\commons-collections-2.1.jar;%OPENJMS_HOME%\lib\commons-dbcp-1.2.1.jar;%OPENJMS_HOME%\lib\commons-logging-1.0.4.jar;%OPENJMS_HOME%\lib\commons-pool-1.2.jar;%OPENJMS_HOME%\lib\concurrent-1.3.4.jar;%OPENJMS_HOME%\lib\derby-10.1.1.0.jar;%OPENJMS_HOME%\lib\jdbc-2.0.jar;%OPENJMS_HOME%\lib\jms-1.1.jar;%OPENJMS_HOME%\lib\jndi-1.2.1.jar;%OPENJMS_HOME%\lib\jta-1.0.1.jar;%OPENJMS_HOME%\lib\log4j-1.2.11.jar;%OPENJMS_HOME%\lib\openjms-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\openjms-common-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\openjms-net-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\openjms-tools-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\oro-2.0.8.jar;%OPENJMS_HOME%\lib\spice-jndikit-1.2.jar;%OPENJMS_HOME%\lib\xerces-2.4.0.jar;%OPENJMS_HOME%\lib\xml-apis-1.0.b2.jar;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib
as you can see j2ee.jar is in %J2EE_HOME%\lib, but still doesn't work. can someone help me?<property name="messaging.client.jar.path" value="Location in your local drive" />
<property name="messaging.client.jar.name" value="nameOfYourFile.jar" /> -
How to create runnable JAR in Eclipse
I have a project in Eclipse with many classes.
Whenever I try to create a runnable JAR, the JAR file created always contains all the classes of the project, regardless whether they are really used or not.
Is it possible to create a runnable JAR in Eclipse, excluding the classes of the project which are not strictly necessary for a given launch configuration?krige wrote:
I have a project in Eclipse with many classes.My condolences on using a build system that apparently has grabbed you by the short & curlies. That can be painful.
Note that:
1) Eclipse can use Ant style build.xml files for controlling most aspects of a build (that are worth mentioning).
2) We provide no support for Eclipse on these groups, but since Ant typically defers to a core set of tools in the SDK, you can usually get away with asking an Ant related question. -
Problem executing .jar file
My program was runnable before by executing the jar file and it doesn't work for some reason now. My manifest file is shown below. The error it gives is "Can't find main class, program will exit". Have I declared my main class wrong or something? It worked fine earlier.
Manifest-Version: 1.2
Main-Class: DHolidaysDatabase_SWiNG/SWDHolidays
Name: DHolidaysDatabase_SWiNG/Setting.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: oWg6g03EbjaxldIbXSrTD72js3A=
MD5-Digest: wcAFPTlHlvUxF0EqC7xyaw==
Name: DHolidaysDatabase_SWiNG/SWDHolidays.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: oWfxPN8XfEwj9XVbud5ga0JNJp8=
MD5-Digest: d8GH20JQt+46GDTNEJ66Gw==
Name: DHolidaysDatabase_SWiNG/Booking.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: XQ8yb35VKGudeY3F6wAeAZUneoc=
MD5-Digest: W9gN8T6hR0X1pMhNwowrQQ==
Name: DHolidaysDatabase_SWiNG/Itinerary.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: 1IrzPAHQZPU/O8YYytImJRMNs48=
MD5-Digest: QzpFCTfG2i/C27wMdLQLIw==
Name: DHolidaysDatabase_SWiNG/
Sealed: True
Name: DHolidaysDatabase_SWiNG/Stop.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: kSaxqmDnhm5IcnQFuy43NKN1BmA=
MD5-Digest: h9VwllxGY+PFAJJMyElOQQ==
Name: DHolidaysDatabase_SWiNG/HotelDataManager.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: zUs+YJsPGVFAaezdIpvTSeKPsZo=
MD5-Digest: gDkFwZczx3w99Gar4NS3sQ==
Name: DHolidaysDatabase_SWiNG/DBaseException.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: nD5NlvfB7t6O8Z81kZEMK2qXeyI=
MD5-Digest: +3YHy7dGiJAK5LLHiEQViQ==
Name: DHolidaysDatabase_SWiNG/Hotel.java
Java-Bean: False
Digest-Algorithms: SHA MD5
SHA-Digest: 1QTjvzw4Qnm0JuMJbeTmEJmSjd4=
MD5-Digest: 8eU7VibFyYLk4CdOH436gg==main-class header should have a class name.
Main-Class: DHolidaysDatabase_SWiNG.SWDHolidays -
Runnable JAR from Eclipse with DLL
Hi,
Is it possible to export a runnable jar from Eclipse that includes and uses a dll?
My simple application uses an 'external' API - JIntelliType - a jar file and a dll belongs to it.
I can run the project fine from Eclipse, but I can't export it to runnable jar. I am a bit lost among classpath, path, build path, native library location, referenced library,..
But maybe it doesn't matter because after trying to look this question up on the net, I am not sure if it is possible to do it with Eclipse (not without additional plugin at least).
Could somebody please help me with this?
Thank you in advance!
lemonbostonYour question is that of deployment. In Eclipse you setup your development environment to include native binaries in the projects working directory. As soon as you leave Eclipse you do not have its facilities anymore and you need to make do with what the JDK has to offer you.So your real question is: I have a jar and a DLL, the jar depends on the DLL. How do I run the application such that the DLL can be loaded by it?
The answer is: you can provide through a system property (java.library.path) which directory Java (and ultimately the operating system) should scan for native binaries, or you can simply put the DLL in the same directory as the jar. The current working directory (the directory where Java is invoked) is always on the binary search pat of the operating system.
The documentation for the java tool is here:
http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html
To pass a system property as a parameter you would do something like:
java -Djava.library.path=path/to/libs -jar yourjar.jar -
Hi,
I made a simple program and I want to create a runnable jar.. I have a config file, How can I exclude the config file when I create runnable jar? so, i can be edited..Here is my heirarchy The hierarchy inside the JAR file is the only hierarchy of interest here.
I will create a runnable jar, but how can I extract the config.properties so its editable when I run the runnable jar.Class.getResource() and friends. -
Applet that archieve jar file fail to load picture
hello...
i already can display my applet , but the ploblem is the applet canot display the picture...
the class that i include in the jar file is can run and will display the picture...
wat is the ploblem?
thanks...This is my full code
package dir.yew;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
public class DirTree
extends JPanel {
public static final String APP_NAME = "Directories Tree";
public static final ImageIcon ICON_COMPUTER =
new ImageIcon("computer.gif");
public static final ImageIcon ICON_DISK =
new ImageIcon("disk.gif");
public static final ImageIcon ICON_FOLDER =
new ImageIcon("folder.gif");
public static final ImageIcon ICON_EXPANDEDFOLDER =
new ImageIcon("expandedfolder.gif");
protected JTree m_tree;
protected DefaultTreeModel m_model;
protected JTextField m_display;
public DirTree() {
DefaultMutableTreeNode top = new DefaultMutableTreeNode(
new IconData(ICON_COMPUTER, null, "My Computer"));
DefaultMutableTreeNode node;
File[] roots = File.listRoots();
for (int k=0; k<roots.length; k++) {
node = new DefaultMutableTreeNode(new IconData(ICON_DISK,
null, new FileNode(roots[k])));
top.add(node);
node.add( new DefaultMutableTreeNode(new Boolean(true)));
m_model = new DefaultTreeModel(top);
m_tree = new JTree(m_model);
m_tree.putClientProperty("JTree.lineStyle", "Angled");
IconCellRenderer renderer = new
IconCellRenderer();
m_tree.setCellRenderer(renderer);
m_tree.addTreeExpansionListener(new
DirExpansionListener());
m_tree.addTreeSelectionListener(new
DirSelectionListener());
m_tree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
m_tree.setShowsRootHandles(true);
m_tree.setEditable(false);
JScrollPane splitPane = new JScrollPane(
new JScrollPane(m_tree)
setLayout( new BorderLayout() );
add( splitPane );
DefaultMutableTreeNode getTreeNode(TreePath path) {
return (DefaultMutableTreeNode)(path.getLastPathComponent());
FileNode getFileNode(DefaultMutableTreeNode node) {
if (node == null)
return null;
Object obj = node.getUserObject();
if (obj instanceof IconData)
obj = ((IconData)obj).getObject();
if (obj instanceof FileNode)
return (FileNode)obj;
else
return null;
class DirExpansionListener implements TreeExpansionListener {
public void treeExpanded(TreeExpansionEvent event) {
final DefaultMutableTreeNode node = getTreeNode(
event.getPath());
final FileNode fnode = getFileNode(node);
Thread runner = new Thread() {
public void run() {
if (fnode != null && fnode.expand(node)) {
Runnable runnable = new Runnable() {
public void run() {
m_model.reload(node);
SwingUtilities.invokeLater(runnable);
runner.start();
public void treeCollapsed(TreeExpansionEvent event) {}
class DirSelectionListener
implements TreeSelectionListener {
public void valueChanged(TreeSelectionEvent event) {
DefaultMutableTreeNode node = getTreeNode(
event.getPath());
FileNode fnode = getFileNode(node);
if (fnode != null)
m_display.setText(fnode.getFile().
getAbsolutePath());
else
m_display.setText("");
public static void main(String argv[]) {
JFrame frame= new JFrame( "FileSystem Viewer");
DirTree dir = new DirTree();
frame.getContentPane().add(dir);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
class IconCellRenderer
extends DefaultTreeCellRenderer {
public IconCellRenderer() {
setLeafIcon(null);
setOpenIcon(null);
public Component getTreeCellRendererComponent(JTree tree,
Object value, boolean sel, boolean expanded, boolean leaf,
int row, boolean hasFocus) {
// Invoke default implementation
Component result = super.getTreeCellRendererComponent(tree,
value, sel, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)value;
Object obj = node.getUserObject();
setText(obj.toString());
if (obj instanceof Boolean)
setText("Retrieving data...");
if (obj instanceof IconData) {
IconData idata = (IconData)obj;
if (expanded)
setIcon(idata.getExpandedIcon());
else
setIcon(idata.getIcon());
else
setIcon(null);
return result;
class IconData {
protected Icon m_icon;
protected Icon m_expandedIcon;
protected Object m_data;
public IconData(Icon icon, Object data) {
m_icon = icon;
m_expandedIcon = null;
m_data = data;
public IconData(Icon icon, Icon expandedIcon, Object data) {
m_icon = icon;
m_expandedIcon = expandedIcon;
m_data = data;
public Icon getIcon() {
return m_icon;
public Icon getExpandedIcon() {
return m_expandedIcon!=null ? m_expandedIcon : m_icon;
public Object getObject() {
return m_data;
public String toString() {
return m_data.toString();
class FileNode {
protected File m_file;
public FileNode(File file) {
m_file = file;
public File getFile() {
return m_file;
public String toString() {
return m_file.getName().length() > 0 ? m_file.getName() :
m_file.getPath();
// Alternatively we copud sub-class TreeNode
public boolean expand(DefaultMutableTreeNode parent) {
DefaultMutableTreeNode flag =
(DefaultMutableTreeNode)parent.getFirstChild();
if (flag==null) // No flag
return false;
Object obj = flag.getUserObject();
if (!(obj instanceof Boolean))
return false; // Already expanded
parent.removeAllChildren(); // Remove Flag
File[] files = listFiles();
if (files == null)
return true;
Vector v = new Vector();
for (int k=0; k<files.length; k++) {
File f = files[k];
if (!(f.isDirectory()))
continue;
FileNode newNode = new FileNode(f);
boolean isAdded = false;
for (int i=0; i<v.size(); i++) {
FileNode nd = (FileNode)v.elementAt(i);
if (newNode.compareTo(nd) < 0) {
v.insertElementAt(newNode, i);
isAdded = true;
break;
if (!isAdded)
v.addElement(newNode);
for (int i=0; i<v.size(); i++) {
FileNode nd = (FileNode)v.elementAt(i);
IconData idata = new IconData(DirTree.ICON_FOLDER,
DirTree.ICON_EXPANDEDFOLDER, nd);
DefaultMutableTreeNode node = new
DefaultMutableTreeNode(idata);
parent.add(node);
if (nd.hasSubDirs())
node.add(new DefaultMutableTreeNode(
new Boolean(true) ));
return true;
public boolean hasSubDirs() {
File[] files = listFiles();
if (files == null)
return false;
for (int k=0; k<files.length; k++) {
if (files[k].isDirectory())
return true;
return false;
public int compareTo(FileNode toCompare) {
return m_file.getName().compareToIgnoreCase(
toCompare.m_file.getName() );
protected File[] listFiles() {
if (!m_file.isDirectory())
return null;
try {
return m_file.listFiles();
catch (Exception ex) {
JOptionPane.showMessageDialog(null,
"Error reading directory "+m_file.getAbsolutePath(),
DirTree.APP_NAME, JOptionPane.WARNING_MESSAGE);
return null;
}
Maybe you are looking for
-
Starting Trial of Adobe Download Assistant
I believe I have downloaded Adobe Download Assistant as a trial to convert a PDF document to a Word Documents. How do I get started?
-
Good morning Forum, the problem that considers is the following one. When I carry out the F110, treating the proposal and brings all the open items. Many of them with error 051. error in calculate of retentions. If I individually select same open ite
-
I am in horry please if some one can help me with my FTP code, thanks
import java.io.*; import java.net.*; import java.util.*; public class Ass_2 { public static void main(String[] args){ String currentPath = new String(); currentPath = "ftp://ftp.scit.wlv.ac.uk/pub"; try { Buffe
-
Leopard 10.5.2 will not load
I know there is already a thread that is similar to my problem, but its not exact I was emptying my trash can when finder froze...I could use any application I watned except for finder or the desktop...I held the power button in the back to turn the
-
what books do I need to buy in understanding photoshop and illustrator Im an old school illustrator form the 1970s-80s and this is all new to me but i love it can you masters help thanks.old school master. ps. we did not have this back in the day.