Solved

How to create a jar files and batch file in SWING?

Posted on 2006-06-14
16
1,086 Views
Last Modified: 2013-11-23
How to create a jar files and batch file for multiple class files in SWING.

How to create a jar file for multiple class files and how to create a batch file to run the application(jar).

When we run the batch file how to hide the dos command screen?

0
Comment
Question by:xpsavy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +4
16 Comments
 
LVL 14

Expert Comment

by:StillUnAware
ID: 16901060
You can't hide DOS window when runing from batch, that's why You make a jar file, add an entry to main class, and it becomes as an executable. Double clicking the .jar will start the app

Jar:
http://java.sun.com/j2se/1.5.0/docs/guide/jar/index.html

0
 
LVL 14

Expert Comment

by:StillUnAware
ID: 16901115
Steps to follow when making an executable jar on Windows:

Let's assume You have Your project classes at the path C:\Project\classes
There is a directory of various classes and packages. Say the class containing starting method 'main' is this:
C:\Project\classes\mypackage\Main.class

1. create a file, say 'manifest.txt' in C:\Project\classes, write the line:

Main-Class: mypackage.Main

Note: after writing the line, press Enter, so that another empty line would be created, now save the file.

2. start the command line and cd into C:\Project\classes. Run this command:

jar cvfm App.jar manifest.txt .

At this point the App.jar file is created. You can test if it runs while double clicking on it. If nothing happens, You should add an entry "." to Your CLASSPATH environment variable. If You need help on the latter, just say so.


0
 
LVL 7

Author Comment

by:xpsavy
ID: 16901126
When we execute jar file we are getting the dos screen. I want to hide that dos screen when we run the jar(application)file.

Once we get the short cut for bat file its easy to hide the window.
But after auto installation the bat file shortut created by setup generator.
Can we control the shortcut file or bat file before creating setup file.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 16902434
try running it with javaw.exe instead of java.exe
0
 
LVL 8

Assisted Solution

by:colr__
colr__ earned 150 total points
ID: 16902878
StillUnAware  - you CAN hide the DOS screen,.

In your batch, use javaw, which returns after the java process has started, thus your batch script will terminate (and the DOS window dissapears) and your java app will continue running.

colr__
0
 
LVL 8

Expert Comment

by:colr__
ID: 16902883
Sorry objects, didnt see you there.
0
 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 100 total points
ID: 16911311
Hi xpsavy,

javaw only prevent using the console window, you also need to use "start" :

in your batch, replace "java" by "start javaw"
0
 

Expert Comment

by:paramu83
ID: 16939690
>>How to create a jar file for multiple class files and how to create a batch file to run the application(jar).

Use the command jar cfm App.jar abc.mf *.class
Here abc is your manifest file.
Create a file with the following command java -jar App.jar . here App is the name of your Application jar file. Write  this command  in a note pad and save it as a bat extension. and try to run it.
0
 
LVL 7

Author Comment

by:xpsavy
ID: 16939823
Hi paramu83

I wanna make the the dos screen invisible when executing the application with out setting the proprties of short cut of the batch file

Thanks for your suggestions

0
 
LVL 8

Expert Comment

by:colr__
ID: 16940436
Use JAVAW instead of JAVA !!!!

colr__
0
 
LVL 7

Author Comment

by:xpsavy
ID: 16940516
Hi colr__

I have tried that its not working
0
 
LVL 8

Expert Comment

by:colr__
ID: 16940533
Can you print the batch file you've got? I use this all the time and it definetaly works.

Are you running your batch file from DOS? If so then you cant get the DOS window to dissapear, but if you double click the batch file, it will open the DOS prompt, start the application, then close the DOS prompt while the program is still running.

You wont be able to start the program from a DOS prompt and have that DOS prompt closed.

colr__
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16940534
Try putting a & at the end of the command to run it in background mode.
0
 
LVL 7

Author Comment

by:xpsavy
ID: 16940542
Thnks colr__

I will try that and let you know
0
 
LVL 8

Expert Comment

by:colr__
ID: 16940562
Heres one I use:

start /B javaw -classpath .;".\JSE\mysql-connector-java-3.1.11-bin.jar" Start > error.txt
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 16940835
Did you tried my suggestion : start javaw ?
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

726 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