I'm trying to create a jar in eclipse. The project contains images and sounds.
I have Resources folder with more folders, but when I run the jar is without the images.
The project structure:
Example:
btServer.setGraphic(new ImageView(new Image("file:Resources/buttonimages/Server.png",100,100,false,false)));
Make sure when you are exporting your Runnable JAR file, you are selecting 'extracting required libraries into generated JAR'.
The other workaround is to put the resources folder from your workspace in the same file location as your jar file.
Hope this helps
Related
I created one jar file and in that i have class files, .classpath file, .project file In sample on github, i see apiproxy, callout and lib folder. when i deploy it, i getting error that traffic can't flow , i get error like traffic.How to upload dependencies jar in lib folder However when i upload my main jar file in resources folder, i don't see any lib folder for dependencies jars. Should i place all jars in one resources folder. in my .classpath file, i can see all lib jars like message-flow-1.0.0.jar, expressions-1.0.0.jar and itextpdf-5.5.6.jar. However in documentation, its given to deploy by maven but i don't know maven, from UI how should i create lib folder and upload jars there.
Okay, in my understanding of your point.
You can upload jar file into apigee from Scripts > import file > in file type choose "JAR" > select jar file from your work space > and finally, define your jar name and then use policy Java Callout to call your jar.
If you have to modified your jar and want to deploy it, delete your existing jar in apigee and upload the new jar by following 1. In case of new jar has the same name of existing jar, you do not need to do anything with Java Callout policy. But the new jar has the different name, don't forget to modified Java Callout for refer to your new jar.
Please create the single jar file which contains jars like message-flow-1.0.0.jar, expressions-1.0.0.jar and itextpdf-5.5.6.jar. As per the apigee doc in create a Java Callout policy and make sure you have mentioned the package name & class name in Java Callout Poliy
<ClassName>package.ClassName</ClassName
<ResourceURL>java://SingleJar.jar</ResourceURL>
I have one JAR named as abc.jar with 15 class files. In JAR file I need to modify xyz.class, so I decompiled to xyz.java and modified it.
How can I update that JAR with the modified Java file? While trying to create (compile) the JAR file I am getting errors.
You can add your newly compiled class to the jar and overwrite the old one, here is how to add xyz.class and xyz.java to the jar :
jar uf abc.jar xyz.class xyz.java
See here for more about updating a jar file.
Or simply you can use any archiving tool, like winrar to open and add files to the jar.
Compile the xyz.java and replace the xyz.class file directly in jar without building the jar again, if the single class has been modified.
I have a jar file (Gestp.jar) . And I have some .Java files (which are web applications) within the jar file
I need to modify a particular .Java file . And then re-create the Jar file and deploy it in a server.
I have extracted the jar file , and did the modification to the .Java file. But unable to create the .class file with the changes , in eclipse as it is a web application.
Please help.
Thanks in advance,
Aditya.T
I have made on Javafx 2 standalone application using netbeans 7.2 IDE. Internally netbeans use ant script for making a build.
Now my application creates some XML file based on some input. For xml creation I have used one third party jar file 'xstream-1.4.3.jar'. Now when I make build and run the application from netbeans IDE only.. application works fine. But when I copy jar to some other location my application stops working.
Reason being when jar file is copied to some other location, application is not able to find 'xstream**.jar' file. So now how to include this jar file (all jar files from class path) in the build so that my application can become distributable.
Thanks in advance.
The manifest file in the JAR is updated to include entries that designate main class and any libraries that are on the project's classpath.
http://netbeans.org/kb/docs/java/javase-deploy.html#build
Include the following code in your build.xml file and change the folder names to suit your project.
<target name="-post-jar">
<jar jarfile="${dist.jar}" update="true">
<zipfileset src="C:/Java/ExcelJars/jxl.jar" includes="**/*.class" />
<zipfileset src="C:/Java/ExcelJars/SX.jar" includes="**/*.class"/>
</jar>
</target>
I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.
I am using Eclipse on Windows XP.
Is there an easy way for me to set up a directory structure and package all my files into a jar?
Add the files to a source folder and they can be included in the jar.
One common way is to have, at the root of your project, a src folder. Within that, folders for java files, and others. something like:
src/
css/
java/
html/
images/
Then you can make each of those subfolders a source folder (Right click, Use as Source Folder) and they should be available to add to the jar.
A .jar is nothing but a ZIP archive, so you can use any program capable of creating ZIPs. Just make sure that you include the manifest and all the class files.
I just added all the files into my Eclipse project (including the txt, html, xml, etc files).
Then I used Eclipse to File->Export->Jar File->Next
Check the "Export Java source files and resources" box.
Done.
If you're using Ant, you can use the jar task (see the examples section for how to include/exclude certain files, etc.)
If you move to an ANT (or Maven, for you Maven fans) then you can automate the Jar building very nicely, and also use it outside of Eclipse (e.g., in an automated build environment). All you need to do is copy the files from your src, jsp, foobar and resources locations into a build staging folder, then Jar the resulting files using ANT's Jar task.
<target name="makejar" depends="compile, copyfiles">
<jar destfile="${jars.dir}/myjarfile.jar" index="true" basedir="${build.dir}" />
</target>
One thing I look down on is including non-source (except package.html files for Javadoc) within the src folder. If you feel you have to do this to achieve something, then you are doing it wrong.