Command line treating a *.class file

I don't know if its possible, but can a jar be set up to run like a normal executable at the command line? Like dir, ls, tar, gzip, etc... So that the command line doesn't have to be built with the first java XXXClass
So:
%> java XXXClass
becomes
%> XXXClass
Is this possible outside of creating a .sh or .bat file that forwards the correct parameters. More or less a wrapper around the command:
java XXXClass <params>
Is this possible to accomplish for a jar? If so how?
What I'm after is not to double click the jar file, though that would be optional too. What I would like is to open a command prompt and just type the file name and have it run like a normal executable without:
%>java -jar
prefix.
L-

Yes and no.
It is possible, on windows at least, to create a .bat file that will call java on your jar, and then to register that as the default handler for .jar files
HOWEVER
Jar files contain no information whatsoever about what external classpath is needed (ie other jars/projects) which makes this relatively useless in a large project
I don't know if its possible, but can a jar be set up
to run like a normal executable at the command line?
Like dir, ls, tar, gzip, etc... So that the command
line doesn't have to be built with the first java
XXXClass
So:
%> java XXXClass
becomes
%> XXXClass
Is this possible outside of creating a .sh or .bat
file that forwards the correct parameters. More or
less a wrapper around the command:
java XXXClass <params>
Is this possible to accomplish for a jar? If so how?
What I'm after is not to double click the jar file,
though that would be optional too. What I would like
is to open a command prompt and just type the file
name and have it run like a normal executable
without:
%>java -jar
prefix.
L-

Similar Messages

  • Capturing command line output to a file possible?

    Hi, i am in need of capturing the command line output to a txt file and need some suggestions on how to do it.
    I have two classes, class A is the one with all the methods and outputs text to the command line (using System.out.print). class B is the one that calls the methods and needs to record the command line output to a file.
    Now the problem i face is not all the output is going to be written to a file and not all the output is going to be displayed on the command line. eg. class B will have a way to select the output mode which is either both to a file and command line or just to a file and display nothing on the command line.
    Is what i am asking even possible? Any suggestions would be great!

    Here is a class I found on the forum that does basically what you need. Just change the code that is updating a Document to write to a file:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class ConsoleOutputStream extends OutputStream
         private Document document = null;
         private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
         private PrintStream ps = null;
         public ConsoleOutputStream(Document document, PrintStream ps)
              this.document = document;
              this.ps = ps;
         public void write(int b)
              outputStream.write (b);
         public void flush() throws IOException
              super.flush();
              try
                   if (document != null)
                        document.insertString (document.getLength (),
                             new String (outputStream.toByteArray ()), null);
                   if (ps != null)
                        ps.write (outputStream.toByteArray ());
                   outputStream.reset ();
              catch(Exception e) {}
         public static void main(String[] args)
              JTextArea textArea = new JTextArea();
              JScrollPane scrollPane = new JScrollPane( textArea );
              JFrame frame = new JFrame("Redirect Output");
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.getContentPane().add( scrollPane );
              frame.setSize(300, 600);
              frame.setVisible(true);
              System.setOut( new PrintStream(
                   new ConsoleOutputStream (textArea.getDocument (), System.out), true));
              System.setErr( new PrintStream(
                   new ConsoleOutputStream (textArea.getDocument (), null), true));
              Timer timer = new Timer(1000, new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        System.out.println( new java.util.Date().toString() );
                        System.err.println( System.currentTimeMillis() );
              timer.start();
    }

  • Setting IIS W3C Extended Log File settings via command line, registry or configuration file

    I am currently in need of a way to set IIS W3C Extended Log File settings via command line, registry or configuration file.  More specifically the 'Bytes Sent (sc-bytes)' and 'Bytes Received (cs-bytes)' settings that are not enabled by default. 
    If anyone knows where I can locate these setting (outside of the GUI) for all IIS versions that would be greatly appreciated.

    I believe I have found a valid solution. You must have the WebAdministration module loaded.  I hope this helps someone.
    Use the following syntax to view current W3C fields:
    Get-WebConfiguration -filter system.applicationhost/sites/sitedefaults/logfile | select-object -expandProperty logExtFileFlags
    Use the following syntax to set W3C fields:
    Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value "Date,Time,ClientIP,UserName,SiteName,ComputerName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,BytesSent,BytesRecv,TimeTaken,ServerPort,UserAgent,Cookie,Referer,ProtocolVersion,Host,HttpSubStatus"}

  • Running from a command line with a .bat file

    I am running my program through a .bat file.
    The .bat file looks as follows:
    java ../classes/HelloWorld
    The .bat file is in a directory at the same level as classes so to get to the class file to run I specify this path. However, it cannot find the class file unless it is in the same directory as the .bat file. Is there a way around this?

    hi,
    as you could have known from the documentation, the java virtual machine executable 'java' expects a fully qualified class name as parameter, no file path. so 'java ../classes/HelloWorld' is of course completely wrong, it should be 'java HelloWorld' and nothing else. if you want to specify a certain path where the class file is to be found, use the -classpath command line option as in 'java -classpath ../classes/ HelloWorld'.
    sincerely, Michael

  • Command line options in Jar files?

    Can I set a command line option in the manifest of my jar file so that when it is double clicked it will invoke the JVM with my command line option??

    Trying to pass to the JVM, not my code.I see.
    Actually I wish sun would just fix the dang option towork
    as it should and not need to be on the commandline...
    And that won't happen.
    Your presumption is that the manifest could somehow do
    the command line options. But by the time the
    manifest and jar file is read, the JVM is already
    running and fully functional. Most of the
    functionality that you see in the jvm is actually
    implemented by other java classes. So the JVM has to
    be running before it can do anything.
    With sun jdk 1.3 a hello world program loads 180+
    classes. This is not pre-loading but rather load on
    demand, it needs all of those classes to load, resolve
    and run the hello world program.
    Actually I am aware of the classes which implement this functionality. It would be VERY easy for sun to empty the connection cache, they just choose to not let us do it for whatever bonehead reason. ANYONE who uses an internet inabled java application/applet will have this issue. Is java supposedly internet friendly?
    Just try it. unplug your internet, use a java application to try and connect to some URL (telnet, ftp, whatever). Plugin your internet connection and see that you will not be able to connect untill you restart your app.
    Crazy. This should be implemented. Its got 2 be a bug. they dont even tell you its command line only...

  • Running mxmlc from command line - unable to open file

    Hello all,
    Just tried to get Flex up and running - but have run into
    probably a simple problem. Here's the scenario:
    1. I've put the flex 2.0 installation folder on my C drive
    such that the path is c:\flex_sdk_2
    2. I've set my system path to reference the the mxmlc with
    c:\flex_sdk_2\bin
    3. I've set up a folder on my desktop for my flex programs,
    creatively called 'flex'
    4. From my command line I use 'xmxlc --strict=true
    --file-specs filename.mxml'
    My output is this:
    Loading configuration file <etc>
    Error: unable to open filename.mxml
    As I said before, probably an easy fix but thought I'd put
    something up to see if anybody knew an answer off the top of their
    head? I'm running Windows XP. Home Edition, V. 2002 if it helps.
    Many thanks!
    Shannan

    Nevermind, figured it out. My files had the .txt appended to
    the end of the file-name.
    *der*

  • Access via command line to the data files for Address Book

    Snow Leopard Server 10.6.8
    Mac Mini 2.66 GHZ Intel Core 2 Duo 4 GB 1067 MHZ DDR3
    I rolled back from Mountain Lion Server to Snow Leopard Server because I needed mySql. At the time I was under AppleCare and they walked me through the steps. However, I ended up with Address Book issues.
    Addressbook user on the Snow Leopard Server was upgraded to Mountain Lion Server. During the rollback process, the Apple tech had me delete the Addressbook user.
    When we finished the rollback, he had me recreate the Addressbook user, but now it is linked to a new, empty data file. I cannot add new contacts nor edit or delete them. So I need to use the command line to view both data store files, find the one that has my data in it and re-attach it to my new Addressbook user.
    Can someone help me with the Command Line commands?
    Thank you,
    Cailyn

    Hi,
    There are a couple of more advanced solution I can think of and I'm actually working on one myself.
    * You can create your own jnlp client that allows you to pass in arguments. That sounds harder than it easy. Building a stripped down jnlp client (e.g. no installer, no applets) using one of the two open-source client as a start takes probably just a couple of days and should be sufficient for in house usage.
    * Another solution is what I'm working on now. You can wrap your own executable around javaws that takes your passed in arguments plus jnlp href and looks up the original in the cache and adds a new one to the cache that it passes on to javaws and suddenly everything works as it should. The magic will be revealed at http://www.geocities.com/vamp201
    - Gerald Bauer

  • Robohelp HTML command-line utility overwrites merged files in .hhp file with absolute paths. Any way to prevent this?

    I have a Robohelp 11 HTML project which uses merged CHM files. I have a help build script which compiles this project using the RH command-line utility. Whenever this runs, RH overwrites the names of the merged CHM files in the .hhp file to use absolute paths (even if the .hhp file is read-only!). I've searched Adobe forums and this appears to be a RH bug. In my case, it doesn't stop the project performing the merge, but it looks like it causes problems when searching the resultant parent CHM (topics matching the search simply don't show up in child projects), as the search cannot necessarily find the merged files referenced in the .hhp when someone performs the search on a different machine. I notice that if I compile via the RH UI, the .hhp entries are not overwritten. So, a workaround is to do the build manually. However, we'd like to automate our help build. Is there any way to prevent the command-line compiler overwriting the merge file entries in the .hhp?

    This was a problem with Rh9, see Item 13 at Using RoboHelp 9
    I haven't seen it reported since but maybe something at that link will help.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • JRE Command Line Install - Error Opening File Java3BillDevices.jpg

    We are installing JRE using a command line script. We keep getting the following error. Is this a bug with the Installer package? Anyone know how to fix it?
    Error opening file C:\Users\USERID\AppData\LocalLow\Sun\Java\jre1.6.0_38\Java3BillDevices.jpg
    Error: 2
    JRE seems to install and work correctly, but the error is perplexing. We are of course installing with Administrative privileges. There are a bunch of posts on the interwebs about this, but nobody really seems to know how to fix it.
    OS: WIN7 64bit
    JRE: 1.6.0_38
    Install Command:
    C:\scripts\Java_JRE_1.6.0_38_32bit_W764\jre-6u38-windows-i586.exe /s INSTALLDIR=\C:\scripts\Java_JRE1.6.0_38_32bit_W764\" IEXPLORER=1 MOZILLA=1 STATIC=1 JAVAUPDATE=0 JU=0 UPDATECHECK=0 AUTOUPDATECHECK=0 /L C:\scripts\LOGS\Java_JRE1.6.0_38_32bit_W764_Install.txt

    On 30.12.2013 10:06, contentdevelopment wrote:
    >
    > Hi Laura,
    >
    > Thanks for your reply, I used to try this installer setupsp.exe, but it
    > prompted the following error:
    >
    > ---------------------------
    > Novell Client Support Pack Install
    > ---------------------------
    > Error: Unable to locate required Support Pack installation files.
    >
    > Attempted control INF: C:\491psp5_IR2\NLS\ENGLISH\SETUP2K.INF
    > Attempted install INF: C:\491psp5_IR2\NLS\ENGLISH\SETUP2K.INF
    > ---------------------------
    > OK
    > ---------------------------
    >
    > And there is no install.ini file in the 491psp5_IR2.zip.
    Please try the full client install:
    https://download.novell.com/Download...d=XBMCanfiNDY~
    CU,
    Massimo Rosen
    Novell Knowledge Partner
    No emails please!
    http://www.cfc-it.de

  • Command-line mp3 tagger and file renamer programs

    I've been looking around and haven't come across a command-line program to edit mp3 tags and rename files based on those tags. Any suggestions?

    Have a look at http://home.gna.org/lltag/ - it's in the AUR: https://aur.archlinux.org/packages/lltag/

  • Command-line to combine obj files (.o) into a Static Library (lib.a) file.

    I have a library that I need to compile for Solaris 10 x86 using Sun Studio. I compile the source files to make obj files by issuing the command:
    Bash-3.0# cc -c -D"_UNIX_" *.c
    This compiles every source.c and produces an object.o file. (Nice, & simple.)
    Now, what is the command-line to combine all those object.o files (along with a few other staticlibs.a) and make one archive, lib.a?
    I've done this many times with the gnu - gcc compilers. Is it possible with the Sun Studio Tools? And where is it documented?
    I thought I had this 'licked' when installed SS12u1 and built the 'Welcome' project. But I have searched the "Sun Studio 12: C User's Guide" from top to bottom, and I don't have a 'clue' :-( ...
    Mike <><><>

    Run the command
    man arto get the details of using ar.
    If you create an archive library newly each time (instead of trying to update an existing library), this command will do the job:
    ar -r myarchive.a file1.o file2.o file3.o ... I recommend building the archive freshly each time instead of trying to update an existing archive. You can get unpleasant surprises when trying to update.
    To link an archive into a program, just put the archive name on the linking command line (with a -L option to point to the directory if appropriate). The position of the archive on the command line matters. The linker scans the archive as it processes command-line options in order. It pulls a .o from the archive only if it has already seen a reference to a symbol that is defined in the archive. Therefore, the archive must follow all files and other libraries that reference the contents of the archive. Example:
    Suppose f1.o uses something from archive.a, and all files are in the same directrory. This command will work:
    cc -o myprog main.o f1.o archive.a This command will not work:
    cc -o myprog main.o archive.a f1.o The reference in f1.o will not be satisfied.

  • Possible to use command line argument in project file?

    In my CI build process I would like to have a command line argument "customer" that should be used in the project file to include customer related files into the project like this:
    <Content Include="..\customers\%(customer)\*">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
    </Content>
    Is that possible?

    Hi pkursawe,
    Try to use the Copy task, topy the custom files into the project, then add these files into the ItemGroup, check this blog post:
    How To: Recursively Copy Files Using the <Copy> Task
    The wildcard will help you to add related files into the project.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Command line to push exe files

    I want to push microsoft updates and exe files using SCCM 2012 R2 
    What is the command line please do guide me
    wusa.exe "Windows6.1-KB2729094-v2-x86.msu" /q /norestart
    wusa.exe  "NET Framework 4.0.exe"  /q /norestart
    or
    "Windows6.1-KB2729094-v2-x86.msu" /q /norestart
    "NET Framework 4.0.exe"  /q /norestart
    or
    Windows6.1-KB2729094-v2-x86.msu /q /norestart
    NET Framework 4.0.exe  /q /norestart

    wusa.exe "Windows6.1-KB2729094-v2-x86.msu" /quiet /norestart
    and
    "NET Framework 4.0.exe"  /q /norestart
    but there are variations etc see:
    http://stealthpuppy.com/installing-microsoft-update-standalone-packages-silently/
    and
    http://msdn.microsoft.com/en-us/library/vstudio/ee390831(v=vs.100).aspx
    Best thing to do is create your packages and test your programs prior to deployment to production computers.
    Here is a script by Jorgen Nilsson which allows you string multiple MSU's together using a wrapper:
    http://ccmexec.com/2012/02/installing-multiple-windows-7-hotfixes-msu-with-sccm/

  • Include command line args in jar file

    If I make and executable jar file, how can I make it so that when it runs certain comman line arguments are included

    If by "executable jar" you mean that you want to click the jar and run the program (and are using Windows), then you would have to alter the Windows file association for jar files that Java created, adding those options to the javaw command. Note that that would affect all jars that are run this was.
    If you're willing to use the "javaw -jar" command, then just add the options to the javaw command.

  • Starting and Stopping FMLE from command line yields corrupt .flv files

    I am using FMLE to record and live stream TV content. In order to this I am remotely calling FMLEcmd in order to start and stop encoding processes. The problem that I am running in to is that the .flv files generated are corrupt. The odd thing is that if I use the exact same profile XML from the GUI, then the encoding process works just fine and results appear as intended.
    Here is the way my workflow works:
    I start the process by calling
    FMLEcmd /p C:\lighttpd\htdocs\xml\default.xml /l C:\lighttpd\htdocs\logs\log.txt
    then at the conclusion of the recording I call
    FMLEcmd /s "C:\lighttpd\htdocs\files\default.flv"
    When I attempt to open the files using FFmpeg I get a codec error saying that no codecs were detected. When I attempt to open the files in VLC I get a error saying that the media types are "Undf". When I attempt to open or modify the files with flvtool2 I get an end-of-file error. My guess is that my stop command is incorrect and somehow abruptly stopping the stream, but I don't know another way to stop the stream. Do I need to specify a specific stream duration in the XML and make sure to call the stop command *after* the duration has been reached? What would cause this codec corruption when the same profile works properly from the GUI?
    Here is the profile I am attempting to use.
    <?xml version="1.0" encoding="UTF-16"?>
    <flashmedialiveencoder_profile>
        <preset>
            <name>Custom</name>
            <description></description>
        </preset>
        <capture>
            <video>
            <device>Osprey-440 Video Device 1A</device>
            <crossbar_input>0</crossbar_input>
            <frame_rate>20.00</frame_rate>
            <size>
                <width>640</width>
                <height>480</height>
            </size>
            </video>
            <audio>
            <device>SigmaTel Audio</device>
            <crossbar_input>0</crossbar_input>
            <sample_rate>22050</sample_rate>
            <channels>1</channels>
            <input_volume>75</input_volume>
            </audio>
        </capture>
        <process>
            <video>
            <preserve_aspect></preserve_aspect>
            <deinterlace></deinterlace>
            </video>
        </process>
        <encode>
            <video>
            <format>VP6</format>
            <datarate>650;</datarate>
            <outputsize>640x480;</outputsize>
            <advanced>
                <keyframe_frequency>5 Seconds</keyframe_frequency>
                <quality>Best Quality - Lower Framerate</quality>
                <noise_reduction>None</noise_reduction>
                <datarate_window>Medium</datarate_window>
                <cpu_usage>Dedicated</cpu_usage>
            </advanced>
            <autoadjust>
                <enable>false</enable>
                <maxbuffersize>1</maxbuffersize>
                <dropframes>
                <enable>false</enable>
                </dropframes>
                <degradequality>
                <enable>false</enable>
                <minvideobitrate></minvideobitrate>
                <preservepfq>false</preservepfq>
                </degradequality>
            </autoadjust>
            </video>
            <audio>
            <format>MP3</format>
            <datarate>48</datarate>
            </audio>
        </encode>
        <restartinterval>
            <days></days>
            <hours></hours>
            <minutes></minutes>
        </restartinterval>
        <reconnectinterval>
            <attempts></attempts>
            <interval></interval>
        </reconnectinterval>
        <output>
            <file>
            <limitbysize>
                <enable>false</enable>
                <size>10</size>
            </limitbysize>
            <limitbyduration>
                <enable>false</enable>
                <hours>0</hours>
                <minutes>60</minutes>
            </limitbyduration>
            <path>C:\lighttpd\htdocs\files\default.flv</path>
            </file>
        </output>
        <metadata>
            <entry>
            <key>author</key>
            <value></value>
            </entry>
            <entry>
            <key>copyright</key>
            <value></value>
            </entry>
            <entry>
            <key>description</key>
            <value></value>
            </entry>
            <entry>
            <key>keywords</key>
            <value></value>
            </entry>
            <entry>
            <key>rating</key>
            <value></value>
            </entry>
            <entry>
            <key>title</key>
            <value></value>
            </entry>
        </metadata>
        <preview>
            <video>
            <input>
                <zoom>100%</zoom>
            </input>
            </video>
            <audio></audio>
        </preview>
        <log>
            <level>100</level>
            <directory>C:\Documents and Settings\Administrator\My Documents\My Videos</directory>
        </log>
    </flashmedialiveencoder_profile>

    If issue of corrupt file after cmd line not in GUI mode. Are you using some automation to copy/paste output flv to someother location?
    AFAIK, after placing stop command, FMLE took some time to write proper EOF in FLV. wait ~10 sec for FMLE to complete file writing process and than play in FLV PLayer.
    I tried manually with steps you mentioned and it's working fine for me.I playerd file in Applian Flash PLayer. "http://www.applian.com/flvplayer/"

Maybe you are looking for

  • Set List Manager Values

    I use a List Manager (based on Popup LOV) in a form. On submit, I insert the list manager values by creating a array using the wwv_flow_utilities.string_to_table function and inserting the values one by one in a loop. I would need to be able to set t

  • Can't get amber light to stop flashing on new express

    Just bought an apple express and am having trouble getting it from flashing amber to green

  • Copying application to the application folder

    Cant drag downloades software (not from app store) into the application folder.   Skype for example... I get the small Plus sign like it wants to copy the file, but nothing happens.  I can make it copy, it just gets stuck to my cursor...

  • Problem with ELSTER and Business Connector

    Hi all, it's not really a XI Problem but I have no idea, where I could post it anyway. For LSTA/LSTB with Elster we installed the Business Connector. To check the settings we execute the report RPUTX7D0. The following error message appears: Testrepor

  • I get a "no" symbol when I try to use the basic brush.

    If I switch to an artistic brush it will work, but every time I try to switch back to the basic brush it just switches itself back. VERY FRUSTRATED... Thanx. Debi