Javac command line program can use class, need tomcat to do same

This may be simple, but any assistance to a newby would be greatly aprreciated. I have a this class file:
import java.io.*;
public class OCrypt
static public String getEncryptedText (String plainText)
Runtime R;
String _encryptedText = "";
char[] someData = new char[16];
R = java.lang.Runtime.getRuntime();
try
java.lang.Process P = R.exec("./OCrypt " + plainText
InputStreamReader ISR = new InputStreamReader(P.getInputStream());
ISR.read(someData);
_encryptedText = new String(someData,0,11);
catch (Exception e)
_encryptedText = "***ERROR***";
return (_encryptedText);
Where ./OCrypt is a compiled program writtine in C in the same folder. A small test program calls the class and C code and works. Now for the tomcat part, I need to be able to call this code from tomcat. I know it has worked in the past on a much older version of tomcat. I need to figure out how to make it work on tomcat 5.5.9
Thanks

Thanks for the reply. Please bare with me. I am reading in the SAMS teach yourself book to know how to create the folder structure. I assumed this folder should be off of my WEB-INF/classes folder. See the full path below.
Couple of things
1 - Your class should be in a package. Otherwise you
will have problems.I added the .class file to a package. Or at least I think I did. I added this line to the top of the code.
package OCrypt;
The file is in this folder:
/var/local/jakarta-tomcat-5.5.9/webapps/ROOT/pss/WEB-INF/classes/OCrypt
Then I ran 'javac OCrypt' in that folder.
2 -
Where ./OCrypt is a compiled program writtine in C
I always keep the C file in the same location as the class. That may be a problem later when tomcat can resolve the class but then can't find that program. I hope that will generate a completely different error.
in the same folder.
In the same folder as what?
The current working directory for Tomcat is normally
[TOMCAT]/bin. Is that the folder you mean? I will put it there if I get the class resolved.
If you want to use this tool, I would say put it in
the PATH for the machine (so it can be found from
anywhere) or use an absolute reference to it.I can put a complete path in the .java file before I compile if you think that will help.
You> can't count on the working directory being where you
think it is. But right now I would just like to create a simple class like adding two numbers together and returning a result. My larger issue is more of a server configuration. I am using a enterprise wide tomcat server and have been told EACH application folder has it's own classpath. I even attempted to write a JSP that would output my enviroment to a simple page. This didn't work because the env was only for the user, not the env AFTER all the startup scripts run for the server.
>
One solution is to use ServletContext.getRealPath().
Is there any reason you couldn't rewrite the
encryption into Java - that way you wouldn't have to
bother with Runtime.exec()
Another alternative would be to use JNI to get a Java
interface to the C class.
http://www-128.ibm.com/developerworks/edu/j-dw-javajni
-i.html
I think either of those solutions are preferable to
using Runtime.exec().

Similar Messages

  • Is there any command line i can use to install a .pkg file to my own directory?)

    I'm a newer of Mac OS X, i need to insatll lots of .pkg package to my mac machine, so i think of install them use a script automatically, but i cnanot find any way to use the command line to insatll the .pkg package to my own forder(like /myapp). can somebody help me? thanks a lot.

    Here's a article on how to move your home dir:
    How to Move the Home Folder in OS X – and Why
    The key basic steps are to copy your home dir to another drive and using the Accounts Preferences advanced options for the your account to redefine where your home dir is.
    With or without the home dir moved you can organize your apps as you see fit.  I keep my apps categorized; doc/text related apps, video apps, calculators, etc.  They could even be on a third drive if you want, but that makes backups a bit more complicated (always backup).
    The advantage of keeping the home dir separate from the boot dir is (a) if the boot drive fails it doesn't take your stuff with it, (b) it allows you to have multiple boot drives and switch among them if necessary while using the same home dir, and (c) if you use a ssd for a boot drive it allows you to use a relatively small ssd (I use a 120GB).
    With a ssd as a boot drive you could still elect to put key apps on it for performance reasons.  I do that for commonly used stuff.  But it's mainly reserved for the boot system.  I try not to put any more that I have to on it just to minimize needless writing to the ssd.  Of course you cannot stop ssd writes by the OS itself (e.g., swap space -- but that too can be minimized with enough ram).

  • Command line program: can it implement keyListener??

    Hello,
    before I take the trouble to learn keyListener implementation, I am wondering if my program could even implement it. It is just a small game that just plays in the command window. I would like it to respond to the user pressing up, down, left and right keys. Is this possible with a keyListener or is this only possible in a 'windowed' application?
    And if you cannot register keys this way from the command line, then how would I make my program interactive. Do you know a link to an API description that explains how to set the program up to give a prompt?
    Thank you very much!
    -Mike.

    guess not...

  • I Baught A iMac 2010 From Someone it came with lion but for the programs i use i need snow leopard but when trying to install it won't boot from usb or cd what can be the problem i've been at this for over 24 hours if anyone ca help it'd be greatly apprec

    I Baught A iMac 2010 From Someone it came with lion but for the programs i use i need snow leopard but when trying to install it won't boot from usb or cd what can be the problem i've been at this for over 24 hours if anyone ca help it'd be greatly appreciate it! Thanks!

    Downgrade OS X Lion To Snow Leopard [Video How-To]
    http://www.cultofmac.com/110614/downgrade-os-x-lion-to-snow-leopard-video-how-to /
    How To Downgrade OS X Lion To Snow Leopard: The Complete Tutorial
    http://www.redmondpie.com/how-to-downgrade-os-x-lion-to-snow-leopard-the-complet e-tutorial/
    How To Downgrade from Apple OS X Lion to Snow Leopard
    http://www.pcmag.com/article2/0,2817,2389334,00.asp

  • Syntax for javac command line in DOS

    Can anyone help me with the proper syntax fror the javac command line? Based on the Java Tutorial, I type the following line while in: C:\Program Files\Java>
    c:\progra~1\java\bin\javac hellow~1.jav
    This returns the following error message:
    javac: invalid flag: hellow~1.jav
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    Rest deleted, you get the drift. A long time has passed since I have used DOS, but I thought that options were just that; they were not essential to run a program. If they are necessary, how do you set an option? for example, I have tried the command:
    C:\Program Files\Java>c:\progra~1\java\bin\javac -g hellow~1
    which gives me the following error:
    javac: invalid flag: hellow~1
    I would really appreciate any suggestions anyone out there has for solving this apparently simple & stupid problem.

    Many thanks for these suggestions. I finally got javac to work by putting the file name HelloWorldApp.java inside of quote marks (i.e. "HelloWorldApp.java"). The program compiled the file, & I now have a HelloWorldApp.class file in my java directory. Unfortunately, I am now having trouble with the next tutorial step: getting java to use the file.
    I am discovering there are some very strange things about DOS since the last time I used it. For example, the cd command recognizes either cd c:\progra~1\java OR c:\"Program Files"\java. If the quote marks are omitted a "file not found" error is returned. There seems to be some sort of problem with ways that long file names are dealt with in DOS. I notice that many contribs to this list enter long file names or directories without quote marks; indeed, this is standard format in the java tutorial. This is probably a really dumb question, but is there someway to tell DOS to recognize long names without quote marks?
    Once again, thanks for the help.

  • Creating a command line program reading AEP/AEPX files?

    I'm new with After Effects SDK, and I wanted to know if it's possible to use SDK to implement a command line program that gets information such as duration and frame rate in AEP/AEPX files.
    aerender, a command line render program provided by After Effects, prints out these information before rendering. But it doesn't seem to be able to print out the information without doing rendering.
    I saw a related thread here: http://forums.adobe.com/thread/844341
    But what I want is simpler. I don't need to alter the AEP/AEPX files. I just want to obtain the information quickly from an AEP/AEPX file. Is it possible to write such a tool using SDK?
    Thanks!

    hi eliang.cs!
    yes, i'm the same guy who answered on the other thread.
    everything the API does, it does through AE as a plug-in.
    so if you have AE running (even just the renderer), your project loaded and your plug-in present, you can access all the data you described with no problem, and export it out in whatever way you want. (a plug-in is actually a DLL, so you can do anything you want, even on an OS level)
    you can access the data on all elements of the project including comps, layers, footage, render queue, ect...
    having said that, you can do all of this using a script instead of a plug-in.
    scripts are much easier to build.
    perhaps there's even a script out there that does what you're looking for, or something very close that could easily be adjusted.

  • Java command line programming in windows

    Here's what I want to do:
    -write .java files in a text editor
    -compile and run them from a command line, rather than using a
    compiler like codewarrior or MS J++
    Here's my problem:
    In a program that produces output, I can't seem to find a way to
    retain the output that goes off the screen in a DOS window. Is there
    a way to enable scrolling in a DOS window, or are there any
    alternative command line terminals for Windows? Any suggestions
    would be greatly appreciated.

    I think you can increase the Screen Buffer size which should give you a scroll bar. For this right click on the icon on the top left of the DOS window -select Properties - Go to Layout tab.
    Another option will be to redirect the output to a file
    java SomeClass > log.txt
    Hope this helps.

  • Cope: a command-line program colouriser

    cope is a wrapper around various command-line programs that takes their output and adds colours - a sort of ornamental cope, if you will.
    It's written in Perl, and requires version >= 5.10, so installation may be a bit complicated if you have to track down the dependencies. It installs several scripts in a directory, each one calling the program it's named after, only highlighting its output using regexes. Then you add this directory to your $PATH, and everything should (hopefully!) be seamless.
    Currently it's in release candidate status - I've been using it personally for a few weeks and nothing catastrophic has happened so far, so there's little point me keeping it private.
    Screenshots:
    Main site: http://stuff.cytzol.org/cope/
    GitHub: http://github.com/cytzol/cope

    PKGBUILD
    # Contributor: denton <e9203.00 gmail com>
    pkgname=cope-git
    pkgver=20091208
    pkgrel=1
    pkgdesc='A colourful wrapper for terminal programs'
    arch=(any)
    url=http://stuff.cytzol.org/cope/
    license=('GPL' 'PerlArtistic')
    depends=("perl>=5.10")
    makedepends=(git)
    provides=(cope)
    conflicts=(cope)
    install=$pkgname.install
    _gitroot=git://github.com/cytzol/cope.git
    _gitname=cope
    build() {
    cd $srcdir
    # Git
    msg 'Connecting to Git server...'
    if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin || return 1
    msg 'The local files are updated.'
    else
    git clone $_gitroot || return 1
    fi
    msg 'Git checkout done or server timeout.'
    msg 'Starting make...'
    rm -rf $srcdir/$_gitname-build
    git clone $srcdir/$_gitname $srcdir/$_gitname-build || return 1
    cd $srcdir/$_gitname-build
    # Build
    PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
    make || return 1
    make install DESTDIR=$pkgdir || return 1
    # Remove perllocal.pod and .packlist
    find $pkgdir -name perllocal.pod -delete
    find $pkgdir -name .packlist -delete
    cope-git.install
    post_install() {
    echo 'Prepend /usr/share/perl5/vendor_perl/auto/share/dist/Cope/ to $PATH'
    post_upgrade() {
    post_install
    First time making a perl package. It puts files that shouldn't be in */site:
    /usr/bin/perlbin/site/envpath
    /usr/lib/perl5/site_perl/5.10.1/IO/Pty.pm
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty.pm
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty/
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty/Constant.pm
    /usr/lib/perl5/site_perl/5.10.1/List/MoreUtils.pm
    /usr/lib/perl5/site_perl/5.10.1/Params/Util.pm
    /usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.so
    /usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.so
    /usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.so
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector.pm
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector/
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector/Functions.pm
    /usr/share/perl5/site_perl/5.10.1/Env/Path.pm
    /usr/share/perl5/site_perl/5.10.1/IO/Stty.pm
    /usr/share/perl5/site_perl/5.10.1/IO/stty.pl
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/CC.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/SEN.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1035.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1738.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1808.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2384.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2396.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2806.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/fax.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/file.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/ftp.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/gopher.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/http.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/news.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/pop.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/prospero.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tel.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/telnet.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tv.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/wais.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/_support.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/balanced.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/comment.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/delimited.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/lingua.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/list.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/net.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/number.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/profanity.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/whitespace.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/zip.pm
    And as shown by the previous list, I haven't fetched these binaries (are they in the repos?):
    Env::Path
    File::ShareDir
    IO::Handle
    IO::Pty
    IO::Stty
    List::MoreUtils
    Regexp::Common
    Term::ANSIColor
    Everything works, except cope_path.pl.
    Last edited by denton (2009-12-08 09:14:37)

  • Fast command-line program which displays connectivity

    Hi
    I'm looking for a command-line program which can show whether or not my network interface has an IP address or not. It could use "ifconfig" to extract the information, I don't really care, but it has to be *fast* and it cannot require root access.
    Thanks

    Thanks, but if someone knows some sed/awk magic to get only the interface's IP address, that would be great!
    EDIT:
    Using the little "sed" I know, this is what I came up with:
    ifconfig wlan0 | grep -w inet | sed "s/^\\s*//" | sed "s/^inet addr://" | sed "s/\\s.*//"
    EDIT2:
    Now I have this reasonable command:
    ifconfig wlan0 | grep -w inet | sed "s/.*inet addr:\([^ ]*\).*.*/\1/"
    Last edited by skorpan (2009-06-07 16:44:19)

  • Uninstalling Command Line Programs

    I've searched these forums and the internet for an answer to this, but there doesn't seem to be anything out there, so I hope this will be helpful to others as well.
    I have some open source command line programs that I downloaded, compiled, and installed as part of some exercises I was doing in a book on open source GIS (geographic information systems). What I want to know is how do I remove those programs? I can find references for compiling and installing these types of programs all over the internet, but nothing about removing or uninstalling them.
    Also, any ideas for good, up-to-date references on learning Unix in Mac OS X would be appreciated too. I'd like to get more into open source GIS, but from the research I've been doing, knowing Unix would help a lot.

    What process did you use to compile and install? Was it a configure, make, make install sequence, which is fairly common? If so, go back to the directory where you did that, and try, for example, 'make uninstall'. This might work.
    Look for output files from the compile and install process (perhaps config.log) that might tell you where files will be installed. Perhaps in /usr/local?
    Is there a README or INSTALL file that came with the source code? Documentation about what was installed where might be there.
    If worst comes to worst, and you're really determined, you could repeat the compile and install steps, but with a before and after listing of all the files in your system, and compare the listings. Or use the find command immediately after the reinstall, looking for recently created or changed files (the 'mtime' option or similar).

  • Is there a command line program that converts WAV to SWF?

    Is there a command line program that converts WAV to SWF?
    thanks

    why you want to do that? you can import your wav into the
    swf!

  • Tagging command line programs in subtle?

    I'd like to be able to tag command line programs so I can assign them to specific views and gravities within those views.
    For example, I'd like to be able to have 'gclacli calm' be recognized by a tag so it appears in my 'agenda' view and assign it a gravity. Is there a way to do this? Right now the best I can do is limit xterm to different views but they still move around when I change  views.
    Last edited by tinySpark (2012-06-14 18:04:12)

    None of these options have worked.
    for the user variables, i just create a new one called "Path" and type in my path to java \bin right?
    This is quite frustrating. Thanks for the help though!
    --Brenton                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to know if my iphone 4s is open line and can use it anywhere or in any country?,

    how to know if my iphone 4s is open line and can use it anywhere or in any country?,like i bougth it in united arab emirates and if im in philippines i can still use it there?.

    If you did not purchase it from an authorized distributor, then there is no way to tell short of trying a different SIM. Even then, it may have been hacked to unlock it.
    That's a risk you take when you buy from the gray market.

  • What is happening about: The GNU Bourne Again Shell (Bash) is a command line utility widely used in many Unix-based operating systems including Linux and OS X.  Researchers have discovered a critical flaw in Bash which could allow remote code executi

    Authoritative advice today:
    The GNU Bourne Again Shell (Bash) is a command line utility widely used in many Unix-based operating systems including Linux and OS X.
    Researchers have discovered a critical flaw in Bash which could allow remote code execution by an unauthenticated user
    APPLE response?

    Also see:
    http://www.macrumors.com/2014/09/26/apple-os-x-users-safe-bash-flaw-update-soon/
    If you are not running a web server
    If you have not enabled CUPS web interface
    If you do not allow anonymous users to ssh into your Mac.
    If all are no, they you are not at risk.
    This IS a very serious bug for web servers, but the typical consumer Mac user is not at risk.

  • الترجمة I have a problem how can I cancel all operations evaluated by so I can use the service again in the same payment method because Apple stuck processes evaluated by on my account and I can not purchase again

    الترجمة
    I have a problem how can I cancel all operations evaluated by so I can use the service again in the same payment method because Apple stuck processes evaluated by on my account and I can not purchase again

    If your CC was banned for fraudulent activity, you will need to use another CC. If the account was disabled, try changing the password to enable it at : https://appleid.apple.com
    Otherwise, try contacting the iTunes store via : https://expresslane.apple.com , choosing iTunes and then iTunes store and from there selecting the topic as it pertains to your query.

Maybe you are looking for