I'm working java swing application.My program run successfully in Eclipse but when i create running jar,it's does not opened.
I created running jar like this
In my option ,problem is that I'm using 4 jar library jmrtd.jar,Scuba.jar and etc.
What am I doing wrong? How i can create jar file,when I use some support libraries(jar files) ?
Please use option "Package required libraries into generated JAR"
Related
I have created a project to collect the daily status in an xls sheet, using the selenium webdriver.
Currently it runs well.
Can I make this project into a standalone application or a executable jar? Or is there some other way to collect the status by clicking on the application or jar to open it without having to compile and run from eclipse?
You can use install4j from below mention URL. It will make executable jar and application.exe also you can make installer for different platforms such as Mac, Windows and Linux.
https://www.ej-technologies.com/products/install4j/overview.html
hope it will help
From Eclipse select Export -> Runnable JAR File
Select 'Extract required libraries into generated JAR'
When you have your JAR file execute :
java -jar MyJar.jar
I have made a Java serial Interface using RxTx libraries in Netbeans 7.2.1 which works fine.
Tested it with NULL modem and it works fine. Now I need to create an exe which I can distribute.
So,Now I am trying to make a jar file for my project. What I did-
and then clean and build to get jar at location
"D:\Glaswegian\Java\Slides\RxTx\SerialCommInterface\SerialCommInterface\dist"
with below structure
with lib having RxTx.jar
Now when I try to run from command prompt:
I get below error
Can anyone please let me know how to resolve this?
Have refered
Run jar file in command prompt
How can I include external jar on my Netbeans project
But not able to resolve it.
The system cannot find some native libraries (which probably are needed by RxTx).
Assuming that the native libraries (*.dll) are in the lib folder - try to run the app like this:
java -Djava.library.path=lib -jar SerialCommunicator.jar
My program works perfectly fine when I run from eclipse but I package it to an executable jar and run it from command line, it runs much slower (almost five times slower). I am even setting the -vmargs while executing the jar
java -Xms40m -Xmx512m -jar jarFile.jar
I do not have any older version of java on my machine. I am not able to understand what I am missing over here. How can eclipse run the same program faster while using the same version of java and same vm arguments. Any help would be appreciated.
Thanks,
karthik
We had a similar issue but the problem was that while exporting Java code as a runnable jar file from eclipse, we were choosing an option "Package Required Libraries into generated jar". This was putting all of the referenced libraries as jar files within the runnable jar, which probably was being unpackaged during every run. Instead of that we used "Extract required libraries into generated jar" option while creating the runnable jar file and the speed of the execution of jar shot up - almost same as it was while running the code within eclipse.
You most likely print a lot to System.out/System.err (either directly or through logging). The Windows terminal emulator needs to render your output, and does it slower than Eclipse.
Try redirecting all output to a file or NUL and measure again.
Instead of checking "Package Required Libraries into generated jar",
use "Extract required libraries into generated jar" option while creating the runnable jar file. This saves a lot of time.
I faced the same issue. The eclipse took 5 seconds to run the application while the jar took 3 minutes. This is due to the way I exported the runnable jar file.
These are mainly two ways to export as a Runnable jar in eclipse.
1). Package required libraries into jar
This will add actual jar files of the libraries into your jar.
This is the cleanest since it separates application class files with
library JARs.
The downside is this makes runnable jar perform very slow.
2). Extract required libraries into generated jar
This way will extract only the actual class files from the libraries
that your application uses and includes in the runnable jar file.
As a result your Jar file will include your application class files
as well as class files of all the libraries used by your application.
This method makes runnable jar perform just like it is run in your
eclipse IDE.
Using this way I was able to run jar application without any lag and
completed just as I run in eclipse IDE taking 5 seconds.
My application accesses a Derby Database and I have added the Derby.jar to the libraries in the project. It runs fine when compiled and runs perfectly inside the Netbeans environment but once I Build the project, only my application.jar file is in the dist folder. The program will still run but once I try doing anything with the database it hangs.
I tried adding the lib folder containing Derby.jar to the home directory of the application.jar but I still get the same problem.
I'm new to Derby and I'm confused by this, any suggestions?
The answer 1 above does not address the fact the you need to first connect to the database in the service tab of the IDE before you can run your application and that is not possible when you run your application outside the IDE.
This is because you don't also add the project external jar dependencies (such as Derby's jar) to the classpath of your project's executable jar. Basicly, try following their tutorial here:
http://netbeans.org/kb/articles/javase-deploy.html#Exercise_1
the chapter entitled "Running the Application Outside of the IDE" and the one after that.
I haven't used Netbeans in a long while so I don't know if they added this functionality to it now, but with Eclipse you can also make a "fat" executable jar, where all the external jars are packed inside that executable jar, and Eclipse adds a special classloader which makes all this work. It's the option called "Package required libraries into generated jar". Maybe Netbeans lets you do that now too, via some export function or something similar.
I need to make an answering questions game and I chose to make it using netbeans. I wonder if I can create an executable so that somebody could "play" the game even if he does not have installed netbeans!
Any ideas please?
In NetBeans set your application as the active project and press F11, which builds the project. This means that your application will be packaged into an executable jar file that you friend can click to run your application.
Once you have clicked F11 you can locate the executable jar file at e.g. ../Documents/NetBeansProjects/ProjectName/Dist
There is a misconception: Netbeans is not a runtime platform. Netbeans is just a tool to build Java applications. You can perfectly create the same Java application with just notepad.exe and the JDK, you only need to have a bit more knowledge and experience to do it rapidly enough.
To run a Java application, all the enduser needs to have installed is a JRE. To create a runnable Java application, all you need to do is to export the Netbeans project as an executable JAR file.
Developed program has nothing to do with IDE. It doesn't need IDE to be executed...
When you build it, a JAR (Java archive) will be created (look in your dist/ directory or your project properties). If you've set up your project correctly, launching that JAR will start your application. See http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html