Java-written classes are called in asp/

Source: Internet
Author: User
During the development process, you may encounter problems in ASP/ASP. net calls the classes written in JAVA to implement functions previously implemented in JAVA. The following is a simple example to illustrate the detailed usage:
1. Create a java file:
Use any editor you like to edit the following content:
Public class hello
Public String helloWorld (String s)
If (s = null)
Return "";
Return s;
Save this file as hello. java
2. Compile the java file as a class:
Run in command mode: javac hello. java
3. Copy the compiled hello. class file to the c: winntjavarustlib directory.
4. Create the following file named test. asp:
Set javaObject = GetObject ("java: hello ")
Msg = javaObject. helloWorld ("Hello World ")
Set javaObject = nothing
Response. write msg
5. Test:
Create a virtual directory test in IIS and set test. copy the asp file to this virtual directory, restart IIS, and access http: // localhost/test in ie. asp. "Hellow World" is displayed on the page, indicating that the call is successful. can be used in the same way as ASP.
Note: In step 2, the 1.3.x compiler must be used for compiling. Although the compilation is normal in jdk 1.4, the No object for moniker error is displayed when I call asp/
6. If other jar packages are imported to the java file, you need to add these packages in step 3. copy the jar file to the c: winntjavapackages directory, and add the classpath variable in my computer --> properties --> advanced --> System variables, the value is the detailed path of the cited jar file, such as c: winntjavapackagesldapfilt. jar; c: winntjavapackagesldapjdk. jar; c: winntjavapackagesldapsp. jar ;. separated by semicolons and ended with decimal points
The test passed in both Chinese and English win2000 and winXP

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.