Jul 25, 2008

Auto Run Java Program - Run Java program on double click

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP
Pages: 1, 2

free web hosting

Auto Run Java Program - Run Java program on double click

cse-icons
Some of the installables in java comes in form of .jar file,
one has to just double click or type "java -jar file.jar", and it starts executing.

The reason for this is a line appended in the MANIFEST.MF file of that jar file.

For writing a similar jar file of your own, just write your java file, then compile the same and create a jar file.
Create a MANIFEST.MF file and the content should have the followings:

CODE
Manifest-Version: 1.0
Created-By: xyz
Main-Class: xyz.MainClass



Here xyz.MainClass is the main class.
Now create a jar file with the manifest file you have created.

jar cvfmM abcd.jar META-INF/MANIFEST.MF .

That's it !!
Double click the jar file and see it running. (provided the jar file association is done)

Reply

eldeo
You can also run java program as a windows service. Use javaservice free tool

Reply

cse-icons
hi eldeo,

can you give more specific info regarding the javaservice free tool.
have u tried it?
Is there a similar solution for *nix?

Reply

jacksonicson
If you want to run your Programm under Windows, you should try JSmothGen! Its open source and it generates an exe file whitch then locates the JVM in the system and starts teh specific class file which inherits the main method!

Reply

cse-icons
QUOTE(jacksonicson @ Nov 12 2004, 05:00 PM)
If you want to run your Programm under Windows, you should try JSmothGen! Its open source and it generates an exe file whitch then locates the JVM in the system and starts teh specific class file which inherits the main method!
*





Is it spelt "JSmothGen"? I tried to search on google with the same keyword but did not find any matches...
If possible pls give me the website address where I can download the tool.

Reply

arunkumarhg
[quote=cse-icons,Nov 13 2004, 05:48 PM]Is it spelt "JSmothGen"? I tried to search on google with the same keyword but did not find any  matches...
If possible pls give me the website address where I can download the tool.
*

[/quote]

Hi buddy

it not "JSMOOTHGEN" but it is "JSMOOTH" .exe converter of java application for MS windows its an open source project you can get it at "jsmooth.sourceforge.net"
and if you want more information or more tools just give these key words in google you will get lots of links ,

KEY WORDS
1) java application installer
2) Java to exe

what else do you wanna know

Cheers
Arunkumar.H.G

Reply

khmerneed
Dear Friend!


I am new to java. and i have tried the below problem.
as a usual time i use ms-dos to command java, javac it look like this

c:>\java\bin\javac test.java (this i do a compile for my java file)
c:>\java\bin\java test (this i do a run for my class file)

I wonder if anyway just double click on test.java then it compile for me without going to ms-dos and run javac?

I also wonder if anyway just double cick on test.class then it will run to let me see the work?

I hope everyone may response to these two problems.

Thanks & Best Regards,
Dorei

Reply

cse-icons
Yeah, I think that is possible...

Just right click on .java file and select open with...
from the list select javac.exe (if it exists) or browse to it and select it.
chek the box.. always open with... and there u r....
double click and it should compile...

I have not tried it yet.. but should def work...
similarly for class files.. associate it with java.exe

If these dont work... i suppose u can write a batch file.. which compiles and runs both...

There is sthg u can do in the registry so that in the context menu u get compile and it would compile with javac.exe
wud try out and let u know..

Reply

khmerneed
Hi,


I have tried so many times, but it is not run that way. when i double click on it, it gone to be open the dos then exit.

I wonder if i have another way.

Thanks & Best Regards,
Dorei

Reply

spirit_valley
QUOTE(cse-icons @ Dec 9 2004, 08:33 PM)
Yeah, I think that is possible...

Just right click on .java file and select open with...
from the list select javac.exe (if it exists) or browse to it and select it.
chek the box.. always open with... and there u r....
double click and it should compile...

I have not tried it yet.. but should def work...
similarly for class files.. associate it with java.exe

If these dont work... i suppose u can write a batch file.. which compiles and runs both...

There is sthg u can do in the registry so that in the context menu u get compile and it would compile with javac.exe
wud try out and let u know..
*


I've tried this method...
It's normal when the DOS window open and exit. Once the DOS command finishes the window will be closed automatically.
And in fact I don't recommend this method since you won't be able to read the error messages from the compiler, although you will still be able to compile the program.
Also note that you won't be able to run the program just by "associating it with java.exe". Reason? Do you remember after you compiled the program successfully (e.g. javac testprog.java), what's the command you need to type in order to interpret (execute) the program? It's (javac testprog). You can't include the ".class" when executing the program, or you'll get an error message. And when you associate a file with a program, Windows just append the filename to the end of the program. So when you associate that *.class file to java.exe and you run testprog.class, you will get "java testprog.class" - it won't work. Try it on your own.

QUOTE(khmerneed @ Dec 15 2004, 09:55 AM)
Hi,
I have tried so many times, but it is not run that way. when i double click on it, it gone to be open the dos then exit.

I wonder if i have another way.

Thanks & Best Regards,
Dorei
*


Like cse-icons said, create a batch file to handle the task. But the easiest way may be to simply use an IDE to write and compile the program.


** Edit
Create a batch file to do the task:
Save the following code to runjava.bat under folder C:\j2sdk1.4.2_04\bin
CODE
@echo off
title Java Compiler
if "%1" == "" goto Help
echo Compiling...
javac %1.java
if ERRORLEVEL 1 goto Error
echo Compile successful. Running program...
java %1
goto End
:Help
echo Compiles and run a java program.
echo.
echo RUNJAVA [filename]
echo.
echo   [filename]   File name of the java source code (without .java extension)
goto End
:Error
echo *** Compile failed ***
:End

What a long post... rolleyes.gif

 

 

 


Reply

Latest Entries

iGuest
About jar
Auto Run Java Program

While creating jar file I faced a problem that is could not find main class ,the program will exit

-reply by Giri

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Recent Queries:-
  1. how to auto execute java program - 0.11 hr back. (1)
  2. autorun jar manifest - 3.52 hr back. (1)
  3. automatic run program in java - 20.48 hr back. (1)
  4. "autorun java" html - 25.81 hr back. (1)
  5. how to execute java file with double click - 42.41 hr back. (1)
  6. double click run java - 45.03 hr back. (1)
  7. run java on php - 47.56 hr back. (1)
  8. execute automatic f11 window.open javascript - 50.75 hr back. (1)
  9. java jar autorun - 68.31 hr back. (1)
  10. program will exist "could not find main class" - 70.13 hr back. (1)
  11. how to compile and run a velocity program of java - 72.44 hr back. (1)
  12. close running program by form java - 87.59 hr back. (1)
  13. auto execute batch programs in java - 89.73 hr back. (1)
  14. how to java application run by double clicking - 95.23 hr back. (2)
Similar Topics

Keywords : auto, run, java, program, run, java, program, double, click

  1. Java Game
    (2)
  2. Learn Java Programming Language Online Step By Step
    (0)
    I had found this site >> http://learnjava.awardspace.com This website is for people who want
    to learn Java Programming Language step by step. This website also includes JAVA lessons from the
    beginning to advanced level. So this site appropriates for the beginner of Java programmer language
    or non-basic Java Programming Language. The lessons are easy to follow and understand starting
    from how to get your PC JAVA ready, the fundamental programming concept and creating the real
    application. Moreover, the working examples are also included. Please enjoy the les....
  3. Java Object[][] Help
    (2)
    I'm having some issues with working with objects . I get an index out of bounds ex.
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 heres how
    I'm using it ---------------------------- Object contestants = new Object {}; contestants
    = "test"; any ideas appreciated. Do I need to specify the initial size on creation or something?
    It seems I answered my own question I gave it an inital size then I was able to add things. But is
    there a way I can add to it on the fly without knowing its require maximum size?....
  4. Java Vs Javascript
    (11)
    I thought they were completely different things. Surely javascript should be seperated from the rest....
  5. Java Or C++
    (2)
    Many having tell me to make my MMORPG in java leads me to agree, But I'm not sure truly is it
    not yet easier, but yet the outcome of programming an MMORPG in java will make it fail or succeed
    more then one in C+= I've learned a lot of variables in javascript, and I don't think that
    java would be too bad either. My true question is, is those who use these languages, which seems
    to give better outcome, and which seems to be more in ease. Regards -PCessna....
  6. Java Applet Query
    (1)
    Hey there, I have made an applet that shows images moving about the screen. I have pause/resume
    buttons that work. But i've noticed that when the applet is interuppted by something i.e moving
    another window over it, it will automatically repaint. My question is how can I stop this? How can
    I make it so that the only time that paint is called is when I want it to be called? Thanks in
    advance!....
  7. Circular Movment/animation In Java?
    (6)
    Hey there guys! How would i go about making an object move about a fixed point for a java
    applet? Thanks in advance guys! Regards, Rod....
  8. Java Part 1
    (2)
    The HTML <script> tag is used to insert a JavaScript into an HTML page. Examples Write text
    with Javascript - http://www.w3schools.com/js/tryit.asp?filename=tryjs_text The example
    demonstrates how to use JavaScript to write text on a web page. Write HTML with Javascript -
    http://www.w3schools.com/js/tryit.asp?file...ryjs_formattext The example demonstrates how to use
    JavaScript to write HTML tags on a web page. How to Put a JavaScript Into an HTML Page CODE
    <html> <body> [color=red]<script type="text/javascript"....
  9. Java In A High School Software Design Course
    Is it good? (5)
    Hi, I'm doing a course called Software Design and Development for HSC in a high school in
    Australia. HSC is basically the courses you do that you get assessed on for University entrance. I
    haven't really done programming before, although I've seen source code and can decipher it
    and make small changes. I am also quite good with the general use of computers. One of the major
    projects we will do in the course is the making of a game (although it's not just game-making
    that we do. We also have to develop a software solution package, although I'm not su....
  10. Beginning Java
    where to start (10)
    does anyone know of any good websites with free java tutorials for people without a lot of prior
    coding experience? i've read some tutorials, but every one i read starts making references to C
    and C++... well i don't know either of those so it gets really really confusing really really
    fast. ive downloaded the sdk but that is it.... i know a pretty good amount of php and a tiny bit of
    perl but those are procedural languages so i dont know if they even helpe me at all with an OOP
    language like java.....
  11. Java Iterator Help
    I need help with a method using iterator (2)
    /** * Remove from the club's collection all members who * joined in the given month,
    and return them stored * in a sparate collection object. * @param month The month of the
    membership. * @param year The year of the membership. * @return The number of members.
    */ public ArrayList purge(int month, int year) { if(month >= 1 && month
    { Iterator it = members.iterator(); ArrayList purged;
    purged = new ArrayList(); int counter = 0; wh....
  12. Java Exercise Help
    I need help to understand this question (2)
    Ok at my Uni they teach you OOP with java, They used to do with C++ i believe but swiched to java
    because its easier to teach people OOP with java apparently. Anyway I've been working on some
    exercises with java (book is 'objects first with java'). I've got this one exercise
    which I cant understand. QUOTE Exercise 4.29 Rewrite getLot so that it does not rely on a
    lot with a particular number being stored at index (number - 1) in the collection. For instance,
    if lot number 2 has been removed, then lot number 3 will have been moved from index 2 ....
  13. Helpful Registry Edit For Java Programmers
    Command Prompt on right click menu (2)
    With this registry edit you can easily open the current folder in prompt without going through any
    Change Directory commands (cd). This is useful for people like me who are programming in JAVA, and
    every time to create class files and test them I have a diificult time just entering the commands in
    Prompt. But if you don't want to use this registry edit you can create the directory in
    C:\ drive like C:\files so you have to navigate very little in prompt. If you are
    experienced in regedit you can do it yourself shown below OR download the attachment and app....
  14. Which Is The Best Java Web Framework?
    JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket (0)
    JSF Pros: Java EE Standard - lots of demand and jobs Fast and easy to develop with
    initially Lots of component libraries Cons: Tag soup for JSPs Doesn't play well with REST
    or Security No single source for implementation Spring MVC Pros: Lifecyle for
    overriding binding, validation, etc. Integrates with many view options seamlessly: JSP/JSTL, Tiles,
    Velocity, FreeMarker, Excel, PDF Inversion of Control makes it easy to test Cons: Configuration
    intensive - lots of XML Almost too flexible - no common parent Controller No built-in Aja....
  15. Help Deploying Java
    (0)
    Hi i just registered to this site. can any1 tell me how to deploy a java app here? i use weblogic
    server on my local machine. thanks Abhishek.....
  16. I Need Help With Java
    (3)
    I dont have much knowlege with java yet. Im a php programer not a java programer but i want to learn
    java and i need this coding to correct so that i can carry on my learning of java. So please some
    one just take some time to help me. Heres what i need to do. QUOTE An incoming request for a
    specific resource, identified by an URI, must be dispatched to the appropriate handler according to
    the server configuration which maps URIs to request handlers. 'HandlerFactory.getHandler'
    must be implemented: CODE public class HandlerFactory {   public String get....
  17. Eclipse Exporting .jar Files
    Could not find main class. Program will exit. (4)
    I need help! I've been using eclipse for a while making little applets, and now I've
    decided to look at some tutorials on how to make simple applications. I've found a pretty good
    tutorial that tells you how to make a helloWorld app with swt and jFace, and also has an example
    file explorer that you can make. They both work perfectly from inside eclipse, but when I try and
    export either one into a .jar file, they don't work anymore. It comes up with a message saying
    "Could not find main class. Program will exit." In the little wizard it has for....
  18. Jsp Or Java Chat Script Like Mig33
    (4)
    so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does
    anyone have java knowlege or knows where i can get a chat script like mig33? i also know this server
    supports jsp so im planing to use it for my application. i was hosted here last year but moved
    because i found a better host. now im back just to use the jsp on this server. Im planing to run
    chat applictions so if any one wants to help me in my project let me know.....
  19. Ajax: Achieve Ajax Program In 5 Lines Of Code!
    (1)
    Well Last night, after a week of irritation and errors I finally created an easy Javascript object
    that easily and quickly allows you to develop an AJAX program in just 5 easy steps! Here's
    the link to the object I've created: http://www.demolaynyc.astahost.com/ajaxConn/ajaxConn.js
    Download it and read the Readme file that's under the same directory:
    http://www.demolaynyc.astahost.com/ajaxConn/Readme.html Basically what this object does is to
    connect to a server-side script (".php, .asp, .jsp, etc"), and what ever this script displays is
    sent back ....
  20. The Power Of Java
    the best application that shows java features (14)
    Java technology has various usage from mobile applications to Enterprise applications. I think the
    power of Java technology in web applications and applets is showed in "meez.com" where u can create
    your own 3d avatars. /rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0"
    alt="rolleyes.gif" />....
  21. Problem With Java Script Popup Form
    Doesnt work in Safari (1)
    This code wont work in Safari, but works fine in Firefox 2. Can someone help. The error pops up
    however. It just doesn't do anything unless you dont pick one and then it says Pick a Windows
    tweak, but if you DO pick one it doesnt even try to load anything. Everything you see below is
    everything inside my PHP Include. If you would like to view my actual site it's
    http://boozkerstweaks.trap17.com There might be PHP errors and stuff right now, but i am working on
    those, but this i can not get. CODE <td  valign="top" class="right">
       ....
  22. Javascript : No Right Click Script !@
    This script will allow you to protect your source coad ! (12)
    This script will help you to protect your source code Add this to Section of your site
    ! HTML <script language=JavaScript> var message="Function Disabled!";
    /////////////////////////////////// function clickIE4(){ if
    (event.button==2){ alert(message); return false; } } function
    clickNS4(e){ if
    (document.layers||document.getElementById&&!document.all){ if
    (e.which==2||e.which==3){ alert(message); return false; } } }
    if (docume....
  23. What's The Relationship Between Javascript And Java
    are they the same or different (5)
    I think most of you always confuse about java and javascript .So I make this topic to talk about it.
    Javascript and Java ,they have the same first four letter. Java and Javascript is the two language
    is very popular in the web world.Java is the general-purpose programming language that you can
    create an application or an applet.Javascript is a script language that looks sort of like java;with
    it you can do various nifty things in web pages.They are independent languages ,used for different
    purposes.If you are interesting in creating a website you should learn how to w....
  24. Java Helpdesk
    All your queries regarding Java Programming goes here. (8)
    Hellow friends, I am creating this thread for all queries and suggestions related to java coding. If
    you face any problem, post it here, and others who have a solution can post the reply here. Hope it
    helps the users.....
  25. One Click Copy And Paste To Clipboard
    in simple Javascript (5)
    I've been search the web for few weeks to see if Java can do one click copy and paste function
    to the clipboard and then I can just Ctrl-V the copied "texts." I initially got this idea when I
    began to approve hosting application. Instead of writing the same message over and over again, I
    decided to make me a page where I can simply copy the code to appropriate answers. And seems like my
    laziness is the mother of inventions /laugh.gif' border='0' style='vertical-align:middle'
    alt='laugh.gif' /> Instead of doing Ctrl-A, Ctrl-C then Ctrl-V to the post board I started....
  26. Java Basic Program Guidance
    (6)
    aving some problems taking in the Java at Uni, Was wondering if anyone could shine some light on it
    for me. My task is to write a program that will ask you to enter 2 words. the program will then
    print out both words on one line. However the words will be seperated by dots that will make the
    total length of the line 40. so if your first word was turtle and the second was abc, the output
    would be turtle...............................abc The program should check for certain conditions:
    1. a word can not be longer than 37 characters; 2. there must always be atlest 2 do....
  27. How To Create Java Button Or Frame
    to be customized (12)
    hi to all!!!! just like to ask if it would be possible if i could make a custom
    button or frame in java. i got tired of using the build infeatures in java. i would like to create
    my own dessign of button or frame.. can it be possible!!! /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> thank!!!! /laugh.gif'
    border='0' style='vertical-align:middle' alt='laugh.gif' /> New Help In! is NOT a descriptive
    topic title. Next time you decide not to follow the posting rules, you will be issued a w....
  28. [help] Java Script: Window.open
    Works with Firefox, not IE (8)
    CODE <HEAD> var popUpWin=0; function popUpWindow(URLStr) {
     if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }
     popUpWin = open(URLStr, 'GunBound Tactics: Screenshots',
    'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90')
    ;; } </HEAD> <BODY> <a
    href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips&
    #60;/b></a> This is a script for opening a new window. It works ....
  29. Java Script Drop Down Menu With Css
    - a full code for a dynamic drop down (2)
    Introduction This is a code that I use to dynamically create the drop down menus. First, you have
    to edit the following code and put it in your Javascript. Notice : /*** SET BUTTON'S FOLDER HERE
    ***/. Edit that to your folder. Also, the /*** SET BUTTONS' FILENAMES HERE ***/. This creates a
    mouseover when the drop down is activated. Put all your onmouseover images under: oversources = new
    array; and your onmouseout images under : upsources. Be sure to set your on and out images above
    each other. CODE /*** SET BUTTON'S FOLDER HERE ***/ var buttonFold....
  30. Java editor
    (72)
    In your opinion what's the best java editor/compiler? i use jcreator le and it works nicely.......

    1. Looking for auto, run, java, program, run, java, program, double, click

Searching Video's for auto, run, java, program, run, java, program, double, click
advertisement



Auto Run Java Program - Run Java program on double click



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE