Java Queries Here..

Faun

Wahahaha~!
Staff member
just a simple query.

How do I send a swing application to end user which will require him to just double click and start it.

I have created a jar file but then I need a bat file to start it. Ok its fine but there also starts a command prompt in background which is a turn off for me.

GOT THE ANSWER :)

Use javaw instead of java
 
Last edited:

mastermunj

In the zone
try executing your jar file with following command:

start javaw -jar myapp.jar

Though, command prompt will appear for a second, then it will disappear..

Or you can create a shortcut to javaw.exe and give above parameters to it, this probably won't even show you the command prompt for a second also.. but i am not sure if this will really work.. You can try it out and let us all know about its result..
 

Faun

Wahahaha~!
Staff member
^^yup, thanks.

Btw is there any way to start the application by just clicking on jar file ?
 

mastermunj

In the zone
For that you can change the file type details in windows and make it open with javaw by default..

For more details see this
 

chandru.in

In the zone
For Windows

You can use this utility to create an executable wrapper around your JAR.

For Linux

Unlike Windows, a simple shell script will do the trick for Linux as it won't open a terminal window unless user chooses to.

Just in case you'd like a platform independent splash screen for your desktop App you can add following line to your Jar's manifest.

Code:
Splashscreen-Image: <image_path_relative_to_JAR>
 

Faun

Wahahaha~!
Staff member
^^Hey,thanks
let me check it out, btw I have made the app in linux but the client and the company will use in windows.
 

ray|raven

Think Zen.
^ Or you could use the SplashScreen class , to display one.

More here : *java.sun.com/docs/books/tutorial/uiswing/misc/splashscreen.html
 

Faun

Wahahaha~!
Staff member
^^its cool but for first iteration am wrapping it in exe (which is in priority 1 condition) and then for next iteration all graphical enhancements are slated to work upon.

One more thing:

I just logged in to XP and found that the jar created is an executable, that means I can run it by double clicking..lolz

Can someone explain me why does it working now on double clickin.

All I did yesterday was

jar cvmf manifest.stab appname.jar .

So is it wise to use it like this or make an exe too, which is a bit large in size compared to jar.
 
Last edited:

chandru.in

In the zone
^ Or you could use the SplashScreen class , to display one.

More here : *java.sun.com/docs/books/tutorial/uiswing/misc/splashscreen.html

Splashscreen class cannot be used to create a splash screen as such. You can use it to manipulate the splash screen only if one already exists (either given in commandline or in JAR's manifest).

One more thing:

I just logged in to XP and found that the jar created is an executable, that means I can run it by double clicking..lolz

Can someone explain me why does it working now on double clickin.

All I did yesterday was



So is it wise to use it like this or make an exe too, which is a bit large in size compared to jar.

It always works upon double-click if the .jar files are associated with "java -jar" or "javaw -jar" commands. The Windows version of JRE installer does the association automatically. On Linux (I tried on Ubuntu), this is done if you install JRE from the repos.

Using the EXE wrapper allows for more customizations to blend with the Windows environment (like creating an icon for your app's executable). It also allows you to bundle a JRE so that your app will work even if the user does not have a JRE pre-installed and .jar associations performed. If you don't bundle JRE, it can also check whether right JRE version is installed and if not will automatically open the JRE download URL. Simple JAR association gives a very unfriendly message to user in such cases.
 

Faun

Wahahaha~!
Staff member
K so I will make exe just in case the system on which it is used is the most obsolete one to support anything :p

Thanks for all the info.
 

Faun

Wahahaha~!
Staff member
One more query guys !

How do I catch memory leaks in my program. Any thing to watch and correct it.
 

chandru.in

In the zone
Memory leaks in Java programs are very rare. It can happen only if you code very badly.

Using appropriate scoping for variables and adhering to basic OOP is all that is needed. The rest will be taken care of by GC. :)
 

parthbarot

In the zone
no mate... for memoery u have to be carful..i mean..u should take care of things which can cause leaks and heap explodes :).

and yah,many have asked abt best IDE for java... so i m suggesting u..

as a professional java prog., u can use Eclipse or IntelliJ Idea..but idea is paid on (abt $500 :D) and eclipse is open source.. so most of corporates are using eclipse.

REGARDS.
 

Faun

Wahahaha~!
Staff member
yeah i know GC does work automatically.

But any way to check the heap and stack for running program. I mean a graphical stat type view.
 

chandru.in

In the zone
Starting with Java 6 update 7, Visual VM is built right into JDK. It is a really good tool for monitoring your JVM instances. Visual VM can be downloaded separately for Any version of Java 6 from here.

Apache's JMeter is a highly advanced monitoring tool too.
 

Faun

Wahahaha~!
Staff member
I'm on linux (Arch Linux). This is the output of java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

So how do I start visual VM ?
 

chandru.in

In the zone
Just type visualvm on your terminal and rock on!

For further references, read *visualvm.dev.java.net/gettingstarted.html
 

Faun

Wahahaha~!
Staff member
Thanks buddy, I owe you :D

But the exact command is jvisualvm.

Thanks you for all your help :)

*i269.photobucket.com/albums/jj44/visio159/Screenshot-JavaVisualVM.png
 

chandru.in

In the zone
Oops! Missed the 'J'. :D

no mate... for memoery u have to be carful..i mean..u should take care of things which can cause leaks and heap explodes :).
If all references are well scoped and proper OO principles are followed, there is no need to worry about memory management (both stack and heap). If you still feel there can be need to worrying about memory, pls give me a sample program scenarios following proper OOP principles, which can lead to OutOfMemoryError.
 
Last edited:

parthbarot

In the zone
thats wht i meant yaar...that u have to take care of references and conections like resources.. which can create probs :)

regards.
 
Top Bottom