0% found this document useful (0 votes)
103 views4 pages

How To Make An Executable Jar in NetBeans

This document provides instructions for creating a standalone Java application using NetBeans that includes external JAR files. The steps are: 1. Create a JAR file for the TinyOS Java tools and add required JARs and class folders to the project. 2. Ensure the project uses the same JDK version as the TinyOS installation. 3. Modify the build file to include the external JAR files in the executable JAR. 4. Clean and compile the project to generate an executable JAR in the dist folder. 5. Launch the JAR either by double clicking or using the jar command in Cygwin if a different JDK is used.

Uploaded by

HackerZworld In
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views4 pages

How To Make An Executable Jar in NetBeans

This document provides instructions for creating a standalone Java application using NetBeans that includes external JAR files. The steps are: 1. Create a JAR file for the TinyOS Java tools and add required JARs and class folders to the project. 2. Ensure the project uses the same JDK version as the TinyOS installation. 3. Modify the build file to include the external JAR files in the executable JAR. 4. Clean and compile the project to generate an executable JAR in the dist folder. 5. Launch the JAR either by double clicking or using the jar command in Cygwin if a different JDK is used.

Uploaded by

HackerZworld In
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Title: Beginners Guide: How to Make a Stand-Alone Java Application with SerialForwarder using an Executable Jar in NetBeans 5.

0 (Beta Version 2). Author: Nathan Ota nota@kingkong.me.berkeley.edu Making an executable jar from NetBeans is rather straight forward, until you need to add any sort of third party files or jars. A quasi-helpful FAQ that is geared towards GUIs can be found here. http://www.netbeans.org/kb/faqs/gui-editor.html#FaqDeployingMatisseBasedProjects Youll need to do a few things to get you jar working. Step 1: jar your tinyos java tools. For reference Ive called my sf.jar. Step 2: add the required compile and run-time JARs and class Folders. First, right-click your project to get the project properties screen, shown below. Use the Add JAR/Folder button to point to the correct resources. In the screen shot below, youll notice Ive added my sf.jar file and the swing-layout.jar file (this is used for the gui, see the netbeans FAQ link above). ***Be sure to add these to both the compile and run options as shown by the tabs to the left of compile tests and run test. Ok, now that youve added the correct JARs and Folders DONT close this window yet, well do more in the next step.

Step 3: make sure your Java Platform jdk is identical to the tinyos installed version. This was a big source of error for me since my NetBeans installation uses jdk1.5 but the tinyos install uses jdk1.4. From the project properties window we were just in Step 2, click on the Manage Platform button were going to specify that NetBeans uses the TinyOS-included jdk 1.4. You should get a similar to below but yours should not have the Java HotSpot this is what well add.

Now, click on the Add Platform button. You should see a screen similar to the one below pop-up. Youll need to navigate your directories to the jdk in the tinyos installation. Notice that my installation places the jdk in C:\tinyos\ and the actual jdk is jdk1.4.1_02. Click Finish to add this to your Java Platforms. Ok, now your done with the project properties.

Step 4: modify your build.xml file. The build.xml file is automatically generated by NetBeans look in your files, it should be next the manisfest.mf file. This is the trick part this will include additional files into the executable jar. Essentially you need to add these lines to include the sf.jar file. <jar update="true" destfile="${dist.jar}"> <zipfileset src="c:/MyJava/sf.jar"/> </jar>

Now, your build.xml should look like this. Notice that Ive added the lines to include the swing-layout.jar for the gui as well this syntax is taken directly from the very first link in this document to the NetBeans FAQ. <?xml version="1.0" encoding="UTF-8"?> <!-- You may freely edit this file. See commented blocks below for --> <!-- some examples of how to customize the build. --> <!-- (If you delete it and reopen the project it will be recreated.) --> <project name="NBgui" default="default" basedir="."> <description>Builds, tests, and runs the project NBgui.</description> <import file="nbproject/build-impl.xml"/> <target name="-post-jar"> <jar update="true" destfile="${dist.jar}"> <zipfileset src="${libs.swing-layout.classpath}"/> </jar> <jar update="true" destfile="${dist.jar}"> <zipfileset src="c:/MyJava/sf.jar"/> </jar> </target> </project> Step 5: Clean and compile your project. NetBeans will automatically generate an executable jar file. NetBeans will (by default) place this jar into the ~/dist folder in the project. Step 6: Double click the jar unless your Windows ( or Mac ) jdk is jdk1.4, this will not work. Instead, open cygwin and navigate to the ~/dist folder. Launch the application by executing the command line jar jar YouJarName.jar.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy