I'm trying to run a simple program to test Java RMI but when I type rmiregistry 6000 into the command window I get the following message.
'rmiregistry' is not recognized as an internal or external command,
operable program or batch file.
I'm probably doing something stupid but I can't find RMI registry anywhere on the computer. Can someone tell me where to find it or how I can download it? I'm using windows 7 and java is up to date.
You are apparently using Windows. The (each) "standard" Oracle JRE installer for Windows puts everything in a subtree that you can override but defaults to **\Program Files\Java\jre<n> or Program Files (x86) for 32-bit java on 64-bit Windows, and copies a few EXEs java.exe javaw.exe javaws.exe and a few DLLs from the jre\bin subdirectory to \windows\system32 which is conventionally in your PATH because that's where lots and lots of other Windows programs are. The installer does NOT copy other programs like rmiregistry unpack200 keytool etc., so for those you need to either add the wherever\jre\bin directory to your PATH or explicitly specify the full pathname for the program. Or copy them to \windows\system32 yourself, but then you have to remember to remove or update them whenever your Java changes (which could occur automatically if you allow Java to auto-update).
The installer does also make some registry settings so you can uninstall from appwiz (like other wellbehaved Windows programs) and the Java control panel appears like other control panels and the auto-updater does its thing unless you disable it, and some settings (I'm not sure if these are registry or elsewhere) so browsers like IE and Firefox can automatically run Java applets.
Related
For installation of my Windows desktop application I create an installer using izpack and then call it from an exe using winrun4j, also part of the izpack installation add another winrun4j wrapper for actually running the application once installed.
The trouble is that for the win4runj.exe to work it needs to be using the correct Java type, i.e if exe is 64bit it must run 64 bit jvm, if exe is 32 bit it must run 32bit jvm. This can be confusing for the user so I was going to take advantage of winrun4j to use an embedded jvm and then make two downloads available
widgetinstaller.exe (32-bit)
widgetinstaller64.exe (64-bit)
But my confusion is that for each download I only want to embed the jvm once but cannot work out how to do this because i have two exes (the installer, and the program itself) , can this be done ?
Update
Have it working if I install JVM twice (once included in install.jar when built with izpack, and once added to the zip file so can be used by widgetinstaller.exe).
widgetinstaller.exe resides in c:\code\widget\installer
Download 32bit jre from Oracle
Install into c:\code\widget\32bitJVM
Edit izpack.xml, adding <file src="C:/code/widget/JVM32bit" targetdir="$INSTALL_PATH"/>
Add for installer vm.location=32bitJVM/bin/client/JVM.dll to c:\code\widget\installer\widgetinstaller.ini
Add for widget itself vm.location=../32bitJVM/bin/client/JVM.dll to c:\code\widget\widget.ini
Rebuild code, and zip up including 32bitJVM in the zip file to create widgetinstaller.zip (this contains 32bitJVM, widgetinstaller.ini,widgetinstaller.exe, widgetinstaller.ico and install.jar)
Unzip and double-click on widgetinstaller.exe to install
But I only want JVM once, I know I need to remove the <file src="C:/code/widget/JVM32bit" targetdir="$INSTALL_PATH"/> from izpack.xml, but then how do I copy my 32bitJVM into program installation folder
that same JVM needs to be saved to the program folder.
Seems this has to be done outside of izpack itself ?
EDIT
Solution is to use Izpack loose packs described at at Can I install a file using Izpack 5 without it being part of the install.jar built by izpack
but it is quite confusing what must be set for the path, documentation incorrectly implies you put in a relative link http://izpack.org/documentation/installation-files.html#the-packs-element-packs.
Example
izpack install.xml is in C:\code\Widget\installer
<pack name="Base" loose="true" required="yes" preselected="yes">
<description>JVM</description>
<file src="C:\Code\Widget\JVM" targetdir="$INSTALL_PATH"/>
</pack>
When package up izpack installation should have:
JVM
install.jar
setup.exe
If the JVM is embedded in the installer then the program cannot use it.
And again if the JVM is embedded in the program then the installer cannot use it.
However you can still do it with only one JVM. This is done by coping the JVM to a local file.
So when you launch the installer with the winrun4j it will launch from the embedded JVM, then at the end of the installation, that same JVM needs to be saved to the program folder.
Your program winrun4j exe can then use the JVM that you saved to the folder to launch the program, you do this by setting the "vm.location" in winrun4j to the location of the saved JVM.
Process:
1) Run the installer exe with the required JVM
2) During the installation save the embedded JVM to a file
3) Once the instillation is complete the program exe can launch using the saved JVM
I have a Java application that needs to implement installation features of making a JAR launch on startup.
I can do this on Window by entering a REG file into the registry, but how can I do this on UNIX platforms? Linux and Mac if the methods are different.
Do Linux and Mac have system startup folders?
Remember that I need to do this programmatically not through system preferences or anything like that.
On Linux, the classic way would be through adding a script in the appropriate /etc/rcN.d/ directory (where N is a number 0-6 representing the 'run level'). I'm not sure whether that's still the recommended way, but it usually is still supported. This would also work with minor variations for other mainstream Unix variants (Solaris, HP-UX, AIX).
On Mac, you have to work harder. The files /etc/rc.common, /etc/rc.imaging and /etc/rc.netboot are related, but there are no /etc/rcN.d directories. There's also a script rc and another rc.local. Typing man rc reveals:
DESCRIPTION
rc.local is now unsupported and has been replaced with launchd(8), which bootstraps itself via the launchctl(1) bootstrap subcommand to read in launchd(8) jobs from the standard locations.
SEE ALSO
launchd(8), launchctl(1)
So, you should investigate launchctl and launchd, particularly launchctl.
This is how I would do it on ubuntu.
First create a bash script to run the java app, similar to.
#!/bin/bash
java -jar "helloworld.jar"
and save it, in this case called 'HELLOWORLD' in /etc/init.d.
Need to make the script executable so need to run
chmod +x HELLOWORLD
Finally to make it run on start up
update-rc.d HELLOWORLD defaults
On Macs I think its launchd, and on linux its init.d. They are config files.
Hi I need to be able to check if a certain software is installed on the clients computer and where, in order to launch it. I found the following three posts as to how to do so on Windows and Mac but I can't seem to figure it out for Linux as there is no registry. Does any one know how this can be done on Linux?
Similar posts for Windows and Mac:
Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction?
read/write to Windows Registry using Java
How can I see the software installed in a Mac OS using a java application?
any help would be greatly appreciated :)
Assuming your security context allows it, you could call out to which.
$ which java
/usr/bin/java
which will output nothing if the program is not found.
Use the
which file
command to find out if the software is installed in the path. If that comes up with nothing then you could do a
find ./ -name "file"
Also check their local bin or .bin if its not included in the path.
Well, basically every binary installed on Linux is in the PATH (environment variable), so if you can find it there, it's there.
There may also be software that installs into other paths, but in this case the user would need to point them out. It is a very uncommon case to have an application in a seperate path and not adding that one to PATH.
I'm trying to run a sample app in Tomcat. I've installed tomcat, set up the environment variable by creating a new system variable called JAVA_HOME which is set to C:\Program Files\Java\jdk1.6.0_20. And I've created a new dir for the web app in the tomcat program directory. In the cmd prompt I navigate to the tomcat program directory and type in bin/startup.sh and I get the following error: 'bin' is not recognized as an internal or external command, operable program, or batch file.
I'm using tomcat 6.0 and I'm on a windows machine. What could the problem?
On Windows you must run the startup.bat file instead of the startup.sh file (note the extension is different).
Also, enter the bin directory before executing the bat script.
cd bin
startup.bat
Your on windows try:
bin\startup.bat
If you try typing in bin\startup.bat on a Windows machine and still get the same error, there's a possibility that Windows is not seeing the batch script where it should be. As a-horse-with-no-name already said, try installing Tomcat to a location where there are no spaces in the path. In your case, anywhere other than Program Files.
EDIT: To resolve this space issue, you can do two things: 1) Install JDK/JRE to a common location without spaces (say, C:\Java) and set it to be JAVA_HOME environment variable. 2) Install Tomcat to another location (say, C:\Tomcat) and proceed from there. Since these are all in common location, I believe you can do this as a limited account user without needing admin privileges.
Try to install Tomcat (and possibly the JDK) into a directory without spaces.
The script you ran is intended for *nix systems. Try bin\startup.bat
I'm a little confused by some of the answers. First, the error you are receiving is from Windows. Nothing to do with Tomcat. The Windows OS thinks you have entered a command, and doesn't recognize it. Files with the .bat extension are always recognized by Windows as Batch file commands....... soooo..... Navigate to the bin directory, again, under your tomcat installation. Then....
Don't append the bin in front of the command. You should do a quick look to make sure that the "startup.bat" file is here (dir *.bat). Then just type "startup.bat".
Seems like I just type "catalina.bat start" (for my tomcat catalina installation)
Synopsis: When calling an executable that links to shared libraries from Java code on Tomcat, I get errors on Windows 2003 whereas the executable works great on a command prompt.
I wanted to do this in Linux, but, alas, got outvoted and have to implement it using Windows Server 2003. Here it goes,
I have a simple Java code running on Tomcat which, when it receives a "start" signal from another server has to run an external executable (written in C++, using shared library DLLs from OpenCV and ffmpeg) like so
String cmd = "c:\\workspace\\process_video.exe -video " + filename;
// Execute the command
Process proc = null;
try {
proc = rt.exec(cmd);
} catch (Exception e) {
System.out.println("VA-> Exception thrown in running the command!");
errorOut.append(e.getStackTrace().toString());
}
Now, when I run the command in process_video from a DOS command prompt, it works (doesn't matter which directory it's issued from). However, when it is run through the Tomcat->my Java code->rt.exec() chain, cmd doesn't get executed, although the exception doesn't get thrown. When I examine Windows event logs, I see an APPCHRASH event for process_video with Fault Module Name cv110.dll, which is one of the OpenCV DLLs I link from cmd.
One solution would be to stuff all the DLLs used in process_video into the tomcat\lib directory, but this hurts my programmatic sensibilities, so I want to know if there is a better way to solve this issue. What user does Tomcat use when running executables on Windows? Maybe I can give more privileges to that user? Should I add the DLL paths to Tomcat's configuration file?
Any help will be much appreciated,
Thanks!
Cuneyt
Add an entry in the PATH evironment variable that points to where your DLLs are. If this doesn't work for your app, you can try adding the entry to Tomcat's PATH. You have to modify the PATH variable of the process that will be loading the executable. Since your Java code probably shares a JVM (and hence a process) with the Tomcat executable, that will dictate which environment the PATH variable will need to be updated.
This is a Windows problem, not a Tomcat problem.
By default, Windows looks in %Path% for DLLs, which may not include the directory of the EXE file.
You can fix this by creating an empty file called process_video.exe.local in the same direcotry as the EXE ( i.e. c:\workspace )
You can also create a .manifest file, but this is a bit more complicated.