when try to execute the servlet containing following code
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("notepad.exe");
It doesn't launch the application in the environment windows server 2003 and Tomcat 5
but a process is being created as notepad.exe in the windows task manager.
In windows xp and tomcat 6 environment launches the notepad
i need to work on the windows server 2003 and tomcat 5
Thanks in advance
In other words, it get launched on your local development machine (WinXP + Tomcat6), but not at a production/test server (Win2K3 + Tomcat5)?
Do you realize that Java Servlet code runs at the server machine, not at the client machine, which are in real world usually two physically different machines connected by a network? The notepad is opened at the server machine (there where the webserver (Tomcat) runs), not at the client machine (there where the webbrowser runs). That it works at local development environment is just because both the webserver and webbrowser runs at the physically same machine.
Login to your Win2K3 environment and you'll see that notepad is opened there.
If you really intend to launch notepad.exe at the client machine using Runtime#exec() (I don't see any business reasons for this, but that aside), then you'll need to provide the client a Java application in flavor of an Applet or Web Start Application served by a HTML/JSP page. This will get downloaded to the client machine and will be executed there.
If you could tell us the requirement to launch notepad.exe, then we could suggest a solution/approach to you.
I think your tomcat runs as a service at the background. When running notepad it is executed with the same logon that your tomcat runs with. Most likely thats a different logon than your desktop-logon and thus the notepad won't be displayed at that desktop!
In your dev environment you started tomcat by executing the wrapper scripts directly. Try to install it as a service and you will get the same problems with XP.
Btw: I don't see a point in running an AppServer and calling notpad at the server. Are you really sure about the design?
Related
I have a swing application which takes some input files, manipulates them, and displays it in its UI. Currently I have a remote headless Linux machine where the data files are (changes everyday). So is there a way in which I can run that application on a remote Linux machine and see its UI on my local Windows machine? I heard it's possible using JNLP stuff. I am very new to this, any suggestion on this is highly appreciated.
Thanks.
You need to install on windows machine X server software and redirect the display of your software to your X server. Example X server software are Exceed, MobaXterm, etc. After you start the X server you should login in to the linux machine and execute
export DISPLAY=<your IP address>:0.0
and then run your software
I am in the process of developing a java web application, and am using the web framework Spark which utilizes Jetty (An http server written in java created by eclipse). Spark makes use of Jetty's embedded webserver functionality, essentially creating a Jetty instance within the app. When creating an executable jar of my application and running on windows, all is well and I can connect to my app locally through http://localhost:81 (I am using port 81). Eventually, I'd like the app to run on a linux server, but upon executing the jar on ubuntu, I am unable to connect to the app locally. I only have a moderate understanding of linux, and cannot figure out why this is happening. I am executing the command 'java -jar G2.jar &' in screen, and it seems to be executing properly. I have ensured that the JDK on ubuntu matches the version installed on my windows machine. I have been testing on an AWS ec2 ubuntu instance and an ubuntu vm, and have had no luck on either.
wget:
wget 127.0.0.1:81
--2016-10-24 21:10:24-- http://127.0.0.1:81/
Connecting to 127.0.0.1:81... failed: Connection refused.
curl:
curl 127.0.0.1:81
curl: (7) Failed to connect to 127.0.0.1 port 81: Connection refused
I have flushed iptables, and even disabled ufw with no luck. Both the ec2 instance and vm are fresh ubuntu installs. I am beginning to think the problem is within Jetty, and that it possibly requires different configuration on linux? The issue is, Spark handles the embedded Jetty instance, and I am unfamiliar with how it does so. Has anybody dealt with this type of issue before?
I fixed the issue. I figured that using the '&' at the end of the command to run the app as a background process would work fine, but guess it does not. Instead, I just used sudo without the '&' and it works now.
I have a few Java programs running on my EC2 instance. I want to profile them using VisualVM. they are not web applications that run on Jetty or Tomcat. I did go through the stuff mentioned here, but I dont know how to set up my VisualVM after I generate the jar files with those commands. Can some help me out?
Thanks
You normally attach VisualVM to the PID of the process you want to profile. If that's Jetty or Tomcat or some other Java EE app server, that means the PID of the app server. If not, it's the PID of the JVM that's running your app.
If you've already got a JVM installed on your EC2 instance, I'd recommend looking in the JVM /bin folder to see if jvisualvm.exe is already there. If it is, fire it up in a separate command shell and attach it the PID of your application.
I've got this new project at work. We are using Eclipse for the project. There are two run configurations, server and client. I have to launch the server and the client independently, and connect to the server using the client. Now, it so happens that this has to be done on both Windows and Linux. (four possible combinations: WS-LC, WC-LS, WS-WC, LS-LC, where W-windows, L-linux, C-client and S-server)
I have Linux on my machine (in which Eclipse is running) and run Windows on a VM. Is there a way I can make Eclipse launch the application in the VM?
I understand I have to build the application locally to a shared folder and send a launch command to windows (using openssh?, not sure). What are the best practices used in this scenario.
EDIT: I need to use this during development, to test my changes to the code. The same application provides both client & server. (yes, horrible, i know :X )
You can publish the server functions as JMX Beans using the MBean interface standard. Then use JMX Console to remotely connect to the server JVM and launch the application.
Eclipse has integration points for remote servers, look to "tomcat configuration" for an example of how it integrates with one remote server.
Whether your application can use an existing server integration solution or not depends heavily on details which aren't present. If you want to actually launch a stand-alone Java process from your remote machine, you generally need a program to capture the request and launch the process.
I'm having trouble using the Netbeans 6.5 profiler to profile the memory usage of a java web app, remotely.
I have followed the steps in the tutorial, and was able to customize a Tomcat instance to start with the profiling agents. I can also attach the Netbeans profiler to the running server: for some seconds, the profiler shows graphs with the memory usage of the server.
However, I am not able to run my deployed web app. After a few seconds, the server is shut down gracefully as if it simply had reached the bottom of its method main (hardly the expected behavior of a web server).
During these seconds, the server is not responsible, and I can't connect to a web application in it, they are simply not deployed.
I do not want to import my app into a new Netbeans project just for profiling it. It's possible to profile a remote app without access to its source, right ? After all, for a few seconds, the server was running and being profiled.
I want to profile a web application in Netbeans 6.5. What did I forget ?
You can use VisualVM tool as well. Follow the below mentioned steps.
1) Run jstatd ( jstat demon process) ( Run on your remote machine where application is running)
jstatd -p 1098 -J-Djava.security.policy=tools.policy ( specify unused port ) if tools.policy file is not specified create it as follows.
tools.policy
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
2) Also specify the following properties before you start your JVM.
#JMX property
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote=true"
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote.port=10992"
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote.authenticate=false"
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote.ssl=false"
3) Start the visual VM on local machine.
a. Under remote tab add remote node.
b. Wait for couple of minutes you will see all the core applications instance will be seen under remote tab.
c. Click on remote node then select Add JMX connections specify node:port (port mentioned above in point 2.)
d. Wait for few seconds you will see JMX connection under remote node.
4) After few seconds you will see new tab appearing under remote node. Double click on the remote_node:10992 you will see the profile table on right hand side.
You can see memory , cpu , thread etc details ..
Are profiling the entire webserver or did you use the profiling filter to profile only your package?
Reducing the interaction between the profiler and the app server itself can solve it.
Check your jvm version. The version used by netbeans should be same as that in tomcat.
Use default ports. If you have changed any ports ensure they are above 1024.
Try to profile the example application in tomcat (remove all other applications). If it is running sucessfully it means there is a memory constraint.
Profiling requires huge memory. use -xms1024m -xmx1024m for tomcat.
If every thing else fail. think of switching to jdk6 and tomcat 6.
After many trials I discoverd that there are lot of limitations in jdk5 and tomcat5. switching to tomcat6 and jdk6 solved the problem for me.
Profiling with netbeans does not work jrockit, ibm jdk etc..
--kiran.kumar