Hi, there is a Java program edited and compiled using Netbeans 6.9.1. After running it's giving proper output in Netbeans output screen. But now I need to run this program in WAMP server. WAMP supports only scripting languages.
I can not run the Java program which I have already built. If I try to run in Tomcat I won't get war file to deploy. Should I use servlets? If so, how can I use it in Netbeans Java applications? Or should I convert (rewrite) Java program to PHP program, if so, how to convert?
How do I run the Java program in WAMP or Tomcat?
If your program writes to standard output, then you should be able to use CGI in some way.
Here are some (admittedly old) links on the topic:
http://www.javaworld.com/javaworld/jw-01-1997/jw-01-cgiscripts.html
http://www.gossamer-threads.com/lists/apache/users/184459
They should at least point in the right direction.
You have multiple options for running your java program:
Convert your program to a library and then integrate it with PHP
Package your application as a Java Web App.
In either case you should definitely have an idea of jsp, servlet read here
It looks like you've created a regular Java program because it outputs to the NetBeans console output.
You can't install a regular Java application to a web platform like that. You need to wrap it in a JavaServer Pages (JSP) application, Servlet or Applet to be able to run it on a web server. After that, install Tomcat or GlassFish as an application server to be able to access it on localhost (both are also optionally available from NetBeans, they can be found in the Plugins menu).
A good resource to start is this tutorial on JSP: http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html
WAMP won't be of any help, it can only serve as a host for PHP content.
Related
For a project, I have to convert a large Java application with an SWT GUI into a web application. Does anyone have any recommendations on starting a project like this? Some ideas I've had are:
Java Play
Java Server Pages
JWebSocket
PHP/Java bridge
Also, one of the problems is that I only have access to the JAR file for the application and need to run it with parameters from a terminal. Would this be possible from one of the options listed above?
I appreciate any help you can provide!
I'm building a web application using HTML and JSP. One of the functionality which provided is converting some texts to speech. In netbeans, I created a Java project, this project contains a Java applet offers the speech task, this applet uses FreeTTS (external JAR file), and it works fine. So after building this project, I added its JAR to the web project, for embedding the applet within the web.
Now, the problem the applet doesn't work from the website, but it works standalone.
Please I need your help to fix this issue.
The FreeTTS developers recommend against using it in an applet, and suggest deploying it via Web Start instead. If it does indeed work fine standalone, that should fix your problem.
If you can't use Web Start, you could consider moving the audio generation to the server and running FreeTTS there.
I'm developing a Java application that is running on WebSphere Application Server 6.1. By now, I've installed a .war file in the server and I'm calling the methods from a jsp file and they're working fine. The questions is: is there any way to develop an application that automatically starts when I press the "start" button of the application after installing it on WAS, avoinding to call the methods "manually" from a jsp? In simple words, a common J2SE application with a main() method exported as a .jar file installed on WAS should start and call the main() method automatically?
I've tried to install an exported Hello World J2SE application but it seems that the .jar is not well formed and apparently it must be a Java EE application.
I'm very new to WAS and Java EE. I really appreciate any help.
A Java EE server is not supposed to run Java SE programs that have a main() method.
Take a look at the Java EE 6 Tutorial, especially the overview of what a Java EE Containers does.
If you use NetBeans as your IDE, you can follow the good tutorials at their site.
Yes this is possible but not directly. You'll have to pack you application as a resource adapter. Also you'll have to hook in the application server for things like creating threads. Check out the IronJacamar documentation.
Finally I did it through a Servlet. When the application starts up, the method init() is called and within this method I do all my stuff.
I've created a Java project in Eclipse that holds applet with Java perspective and another PHP project with PHP perspective that holds file that has javascript to communicate with the java applet.
Unfortunately I don't know how to setup the Java files into the PHP project so that the applet works from my localhost.
I had the applet somewhat working when I put the PHP files into Java project and ran it like that but I need it other way so that I can run from my PHP project.Anything is great. Thanks
Keep your Java and PHP projects completely separate. Keep in mind that you can serve up your Java applet in any number of ways, your PHP implementation is just one. With that knowledge in hand what you really want to do is to decide where your Applet bundle is going to live. I recommend you create a simple HTML file on your server and test loading the applet from whatever location you decide on. Then in your PHP file just write code to spit out the exact same HTML to the client.
put the PHP files into Java project ... wrong way!
Try using another tool to edit your PHP scripts. Setup XAMPP server for development environment.
I am on a Java learning spree recently, however I am normally a .NET developer. (So please forgive my newbie questions.)
In .Net I can develop ASP.Net pages without using IIS, as it has a watered down web server (Cassini, I think it's called).
Does Java or a Java IDE have something similar so I can write and test JSP and Java Servlets without the need of a full-blown app server (Tomcat etc.)?
Also if there is one, does it work on Windows?
Tomcat actually isn't a fullblown appserver. It's just a servlet container (i.e. implementing only web component of the (indeed huge) Java EE API) It's only around 6MB big. Glassfish, JBossAS, Weblogic and Websphere as being full Java EE API implementations may be called as "fullblown appservers".
You can also consider Eclipse Jetty. It has a small footprint (download is only 2.2MB) and is useable as an embedded server and even runnable from a plain vanilla Java class.
As to IDE's, both Tomcat and Jetty are by default supported in "Eclipse for Java EE developers". You can easily integrate them in Servers view and then just associate your web project with it. Here's a nice video tutorial how to get started with servlet development with Eclipse and Tomcat.
As to working on Windows, Java is platform independent. You just need to have a platform-compatible JRE installed. Then any Java software will be able to run on the particular platform. Sun has a JRE for Windows --which is by the way also included in the JDK, if you already have one.
In the Java world the usual way to develop JSP based applications is to have a web container like Tomcat inside the IDE, and there are many ways to do it.
The easiest way to get started is to use Netbeans with a bundled web container - download the "Java" one from http://netbeans.org/downloads/index.html and install it.
After starting Netbeans 6.8, "File -> New project", choose "Java Web" to the left, and "Web application" to the right, and "Next". "Next". "Next". "Finish".
The editor now opens on "index.jsp" in a new project. Select "Debug -> Debug Main Project" and after a while a browser opens showing "index.jsp".
Switch back to Netbeans. Insert this line
<%= new java.util.Date() %>
just before the </body> end tag, and save with Ctrl-S (or "File -> Save").
Switch back to the browser. Reload the page. See the date shown. Repeat :)
That's it.
You can hook up your ant scripts to hot deploy to a local tomcat instance. That's the closest thing I can think of to the .NET development environment.
Eclipse can embed a dev version of Tomcat, and most other IDEs offer a dev server too, I should think.
But also I should also point out that obtaining & setting up Tomcat is quite a bit simpler than setting up IIS. Just download a zip file and unzip -- poof! you're done!
When I was playing with JSP a while back I used NetBeans which has a Web & Java EE-installer, that
Provides tools for developing Java SE,
Java EE, and web applications. This
download option also includes the
GlassFish V2 UR2 application server
and Apache Tomcat software.
Try Jetty http://jetty.codehaus.org/jetty/
Jetty is an Open Source HTTP Servlet Server written in 100% Java. It is designed to be light weight, high performance, embeddable, extensible and flexible, thus making it an ideal platform for serving dynamic HTTP requests from any Java application.
EDIT: corrected link.