How to create a .bat file to run *.class files?

Hello.
I have compiled java *.class files.
I would like to make a shortcut on my desktop to run my Java programs.
How to write a shortcut (.bat file or something else) to run Java programs?
Thanks

1) Make it into an executable jar file (internet search for "java executable jar" will give you lots of help)
2) Write a batch file. If you do not know how to do this, a Java forum is not the place to find out. Do an internet search or find a windows support site.

Similar Messages

  • How to create a bat file by abap?

    hi~
    i ask a elementary question.how to create a bat file in my local pc?how to write some message in this bat file ?thank you !

    execute bat-files
    Reward Points if it is helpful
    Thanks
    Seshu

  • How to create a .bat file

    Hi,
    I want to transfer and run my program on a computer
    that don't have JDK. I want to create a .bat file or
    something like that. How exactly is this done? I guess
    I have to include all the javaclass files that my program
    is using. Can I put everything in one directory and than
    zip it and create the path in a .bat file?
    Please help me I can't figure this one out...

    Steps of creating a DOS batch file.
    1. The machine that will run these Java programs needs the JRE or JDK installed on it. If it is an applet, a web browser is OK.
    If you are using just standard core Java packages such as
    java.awt.*
    java.awt.event.*
    java.io.*
    java.net.*
    (and others... not extension packages such as javax.swing.*, Java 3D, etc)
    you may not need JDK and can just use Microsft's JVM which is jview.exe on the windows directory, C:\Windows
    2. Create a new directory to store all the Java class files, data files, images and other resources that the program makes use of.
    3. Create a batch file that will install and/or run the program IN THE SAME DIRECTORY as the class files.
    4. Go into the batch file properties by right mouse clicking on the batch file and selecting properties. Go to the programs tab at the top and look at the 'working' and 'cmd line' properties. These two need to be blank. If there are any values in there, then delete them.
    5. Zip the directory using WinZip and then create a self-extracting executable. (Just right mouse click on the directory and select the 'Add to zip' option).
    6. Save to a floppy or another location.
    Here is a sample batch file:
    (Assumes that the directory with all your files is called myprog and is saved on the floppy disk
    Your program that has main method is called Main)
    rem -----start batch file--------
    @echo off
    cd c:\
    mkdir myprogs
    cd myprogs
    copy a:\myprogs\*.* .
    echo all done!
    echo running application...
    java Main (or jview Main)
    rem -----end of batch file--------
    If you are using UNIX/Linux then a shell script needs to be created. This is then executed by using the commands:
    sh <myshellscriptname>.sh
    Hope this helps!
    Rizwan

  • HOw to create a Batch file for java application and whats the use of this ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    First of all, you're OT.
    Second, you can find this everywhere in the net.
    If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
    javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
    Otherwise use:
    javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
    Don't specify the .class extension.
    Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
    The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
    This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
    Finally add dukes and give 'hem away.
    Bye.

  • Creating windows .bat file from within an oracle .prc or .sql file

    I am currently converting a series of batch jobs on a windows server to use an Oracle db rather than a MS sql server db. In ms sql, I could call \mssql80\binn\isql and it allowed me to pass in .prc files and have a .bat file returned. the .bat file is then executed in the calling bat to set variable value returned in the sql call...
    I am thinking I can spool a bat file, however, i do not know how to populate this file with the literals and query values needed to create the bat file which sets values used for further processing in the original calling bat file...
    Does that make sense? any help is greatly appreciated.

    Hi,
    There can be various ways to do this.
    First and simple way is simply spooling out the batch file. Suppose you have a .sql file with all the queries, run the .sql from DOS prompt like this,
    c:\> sqlplus -s username/password@tnsname @mysqlfile.sql
    the contents of mysqlfile.sql can be,
    rem ---------------------
    set echo off feedback off head off
    spool c:\batch_files\mybatch.bat
    select 'start \w ' || win_app_name from mytable ;
    spool off
    rem ----------------------
    exit
    So, you can get the batch file created with desired name in desired directory. The '-s' mentioned in the sqlplus command is important.
    There is another difficult/tedious way, but that can give you exact output. With UTL_FILE package you can write an operating system file from pl/sql code, stored procedure/package. Its look more like C-language code, but is usefull. So, write a sql or stored procedure and create the batch file. For that matter, you can write any type of file, just you can write whatever you want to a file.
    Cheers

  • How to create different log files for each of web applications deployed in OC4J

    Hi All,
    I am using OC4J(from Oracle) v1.0.2.2 and Windows2000. Now I want to know
    1. how to create different log files for each of my deployed web applications ?
    2. what are the advantages in running multiple instances of oc4j and in what case we should run
    multiple instances of OC4J ?
    3. how to run OC4J as Windows2000 Service rather than Windows2000 Application ?
    Thanks and Regards,
    Kumar.

    Hi Avi,
    First of all I have given a first reading to log4j and I think there will some more easy way of logging debugging messages than log4j (If you could provide me a detailed explanation of a servlet,jsp,java bean that uses log4j and how to use log4j then it will be very helpful for me). The other easy ways (if I am not using log4j) to my problem i.e creating different log files for each of web applications deployed in oc4j are
    I have created multiple instances of OC4J that are configured to run on different ports and so on each instance I have deployed a single web application . And I started the 2 oc4j instances by transferring thier error/log messages to a file. And the other way is ..
    I have download from jakarta site a package called servhelper . This servhelper is a thread that is started in a startup servlet and stopped in the destroy method of that startup servlet. So this thread will automatically capture all the system.out.println's and will print those to a file. I believe that this thread program is synchronized. So in this method I need not run multiple instances of OC4J instead each deployed web application on single instance of oc4j uses the same thread program (ofcourse a copy of thread program is put in each of the deployed web applications directories) to log messages on to different log files.
    Can you comment on my above 2 approached to logging debugging messages and a compartive explanation to LOG4J and how to use LOG4J using a simple servlet, simple jsp is appreciated ...
    Thanks and Regards,
    Ravi.

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • How to create a Batch file for java application  ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    [http://static.springsource.org/spring-batch/]
    Assuming you want to develop a batch application rather than actually just create a .bat file ..

  • How to create a PAR file from EAR file

    Hi,
       I have created an Web Dynpro Application . When i deploy it in Remote J2EE Engine, it will deploy as EAR file. It then runs as normal Web Application in Web browser. My requirement is to create an iView for my Web dynpro appn in EP. That is possible only by creating a PAR file. so How to create an PAR file from EAR in NWDS(NetWeaver Developer Studio).
    How to access the EAR file in NWDS or J2EE ?
    Thanks in Advance ,
    By
    Saravanan

    Hi,
    To create a iview,
    log on to portal, New iView and select SAP webdynpro iview.
    It will ask for namespace which is usually , local/Project Name
    and application name is the name of the application.
    We dont have to create par file for this requirement

  • How to create the log file in remote system using log4j.

    Hi,
    How to create the log file in remote system using log4j. please give me a sample code or related links.The below example i used for create the log file in remote system but it return the below exception.Is there any authandication parameter for accessing the remote path? Please help.
    public class Logging
    Logger log=null;
    FileAppender fileapp=null;
    public Logging(String classname)
    try
    log = Logger.getLogger(classname);
    String path=" [\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt|file://\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt]";
    fileapp = new FileAppender(new PatternLayout("%r [%t] %-5p %c %x - %m%n"),path, true);
    log.addAppender(fileapp);
    log.info("Logger initilized");
    }catch(Exception ex)
    ex.printStackTrace();
    java.io.FileNotFoundException: \\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt (The network path was not found)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
    at org.apache.log4j.FileAppender.<init>(FileAppender.java:109)
    at annwyn.logger.BioCapLogger.<init>(Logging.java:23)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Please help.
    Thanks in advance.
    Saravanan.K

    Sorry path is missing for the above request.
    path="\\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt ";
    please help.
    Saravanan.K

  • How to create a PS file out of Freehand MX?

    I am new to these forums, and wonder if anyone can help
    clarify a question:
    How to create a PS file with fonts embedded, out of Freehand
    MX?
    I am very late in making the transition to OSX /Freehand MX /
    CS1 (better late than never).
    Up until recently I have been using Freehand 8/9 under OS 9.2
    to create a Postscript file, selecting 'Embed All Fonts' in the
    save to file dialog box. Then distilling the PS file through
    Acrobat Distiller 5 with press ready settings. All works fine and
    no problems with the printed results.
    Now running FH MX under OSX (10.2.8 Jaguar?) I have added a
    virtual PS printer but I am unable to work out how to successfully
    embed fonts, and would much appreciate any advice!! Thanks in
    advance.

    I would be careful saying that the resolution is correct for
    any
    publication. Newspaper print is typically at 85 lpi where as
    standard
    press printing (even magazines) is 150 lpi or higher. These
    require 170
    and 300 ppi images, respectively. Not knowing what the
    D6Dispatch
    preset gives you I would think it's closer to 170 than 300
    which would
    not be enough for most print needs other than newspaper.
    Also, your directions for finding the PS option are when
    using OS X 10.3
    or earlier, which is what the original poster is using. For
    others, in
    10.4, it is found in the "PDF" button found at the bottom of
    all option
    sections. It is labeled oddly as "Save PDF as PostScript".
    Rich
    JerseyThursday wrote:
    > This is how I create press ready PDF files (for print
    ads) from Freehand MX (os
    > X) with the fonts embedded.
    >
    > Out of Freehand, I click print. In the print dialog box,
    on the third
    > pull-down bar (should say ?copies and pages?) I pull it
    down to the ?output
    > options? selection. From there I check the box ?save as
    file? and then select
    > postscript from the format options. This creates a PS
    file.
    >
    > I then distill this PS file in Acrobat distiller (comes
    with Acrobat
    > Profesional) using the job option D6Dispatch (this is a
    Columbus, OH
    > newspaper). You can download this distiller option free
    from:
    >
    http://printads.thisweeknews.com/
    >
    > Works great for 4 color and black and white ads. The
    fonts are embedded and
    > the resolution is correct for any publication
    >
    >

  • How to create a .exe file for a java application

    Hi, I want to create a .exe file for a java application I am developing so that I can schedule it to run at a particular time using Windows Scheduler on WinNT. Is there any way to accomplish this? Or is there any other way in which a Java application can be scheduled to run at a particular time on Windows everyday?

    Create a .bat file and run that. Just have, in the .bat file:
    java YourClassName Alternatively, you can use javaw YourClassName (without *.bat, just put it into Windows Scheduler like suggested above).
    using javaw won't pop up any window...

  • How to use a bat file to change plug-in control panel settings?

    Hi,
    The company I work at has old applications that rely on the MS JVM shipped with IE so we cannot activate the Sun Java plug-in for all users.
    The applet we are developing has to write to disk and thus has to be signed. We do therefore need to run a modern Java version for our users. We have about 5000-7000 users so we would need to create a bat file that would automatically be run for our users. That bat would set that the Sun Java plug-in will be used for Intenet Explorer.
    Does anyone know which (registry-?) setting it is that is changed when the Internet Explorer box is checked in the Java plug-in control panel?
    All help is greatly apprechiated.
    Best regards,
    Helena

    Try this one:
    HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Plug-in\1.5.0_06
    Where the 1.5.0_06 might be a different version.
    There is a value named UseJava2IExplorer. 1 is enabled (Sun's), 0 is disabled.

  • How to create the exe files for java application

    How to create the exe file for java application?
    got any software to do that?
    Thanks

    In terms of converting java applications into exe files, there are 3 schools of thought:
    1) Instead of converting it to an exe, convert it to a jar file. Jar files are more portable than exe files because they can be double-clicked on any operating system. The caveat is that a Java interpreter must be installed on the target computer for the double-clicking to work.
    http://developer.java.sun.com/developer/Books/javaprogramming/JAR/
    2) Create an exe launcher that, when double-clicked, attempts to find a Java interpreter on the local computer and launches the Java application. The exe file is still double-clickable but whether your java application runs depends on whether a Java interpretor is installed on the target computer.
    http://www.sureshotsoftware.com/exej/
    http://www.objects.com.au/products/jstart/index.jsp
    http://www.duckware.com/products/javatools.html
    http://www.ucware.com/jexec/
    http://www.rolemaker.dk/nonRoleMaker/javalauncher/
    http://www.jelude.cjb.net/
    http://thor.prohosting.com/~dfolly/java/index.html
    3) Create an exe launcher that bundles a Java interpretor. Same as above but when the exe file is double-clicked, it searches for a Java interpreter and if one is not found, it installs one on the target computer. The caveat is that the exe file would have an overhead of 10 MB in size for the interpreter.
    http://www.excelsior-usa.com/jet.html (evaluation version available)
    4) Convert the Java application into a native exe file. The caveat is that if you use Swing for your GUI, it won't be converted. Also this option is still somewhat experimental.
    Can't think of any free options right now.

  • Creating a .bat file to compile .java files

    Hi,
    I am trying to create a .bat file to compile java files. I have created the .bat in the same folder as teh .java file I am trying to compile. I know the path is set to the proper folder to find the compiler, but I keep getting an error saying the system can not find the specified file, or can not read fileName.java. Everything is spelled correctly, and I know it works because it will compile from the command prompt. Any suggestions?

    rather than including a sourcepath, just specify the full location. Using your example, this would read like
    javac "C:\Documents and Settings\Kevin\Desktop\School Stuff\AP Comp Sci\PowerPoints\Chapter 02\Executables\Section 2.2\Facts.java"Note that everything is inside the inverted commas " "
    I tried this on a hello world Java program inside a brief case and it works fine.
    The class file is created inside the briefcase.
    If you want to create a bat file to do this from anywhere, modify your batch file to look like this:
    c:\
    cd "C:\Documents and Settings\Kevin\Desktop\School Stuff\AP Comp Sci\PowerPoints\Chapter 02\Executables\Section 2.2"
    javac %1.java
    java %1Again, you would use this as follows
    mybat FactsDon't forget to leave out the .java extension.
    This will compile the java file and attempt to run it for you.
    If you don't want it to run, leave out the java%1
    If you create other java files in this same briefcase folder you can use mybat to compile them too.
    For example
    mybat Facts2

Maybe you are looking for

  • ICal day view header date error

    I'm having an issue with the date header in the iCal day view.  No matter what day I select the calendar displays Saturday, November 27th, 2010 in the header (at the right top corner of the screen).  The date near the top of the agenda on the left si

  • Blocked plug ins - I paid apple support to fix this just a month ago, but it is doing it again. now what?

    Blocked plug ins - I paid apple support just one month ago to fix this problem,and they installed a new version of flash player. Now it is happening again. Is it possible for flash player to already have a new version? Mine is a 2011 MacPro OS X Do I

  • Adding a movie in iWeb using a movie template.

    I wanted to add a small QuickTime movie to my web site. I added a movie template page to the site and then dropped the movie to the box. In iWeb, I am able to click on the play button and the movie plays just fine. But when I publish the site and upl

  • Idoc processing: Limit of # of segments

    Hi All, Can you tell me what is the limit of segments when processing an Idoc via BAPI? I know that for some (FI) it's 999 but I'm wondering if it is the same for all Idocs. Thanks.

  • Do you know an app to read books on my mac

    hello I need an app where I can read the books I've bought ibook store. I read them in my IPAT and on my iphone but I need some app to read them on my macbook pro