Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 947543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:05:51+00:00 2026-05-15T23:05:51+00:00

i am working with Eclipse to develop a application in J2ME.In This application i

  • 0

i am working with Eclipse to develop a application in J2ME.In This application i am using a servlet called HitServlet and a J2me Class HitMIDlet.
I want to run this project using Eclipse.But i do not what is the directory structure
and how i make directory structure.
I am alredy configure J2ME plugin and Tomcat in my eclipse.
But i do not what is the directory structure of my classes in my eclipse.
To get the proper out put.
I want when i run j2me class(HitMIDlet) it hit the servlet(HitServlet) and give the out
put.

this is my J2me Class code:

import java.io.*;

import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class HitMIDlet
    extends MIDlet 
    implements CommandListener {
  private Display mDisplay;
  private Form mMainForm;
  private StringItem mMessageItem;
  private Command mExitCommand, mConnectCommand;

  public HitMIDlet() {
    mMainForm = new Form("HitMIDlet");
    mMessageItem = new StringItem(null, "");
    mExitCommand = new Command("Exit", Command.EXIT, 0);
    mConnectCommand = new Command("Connect",
        Command.SCREEN, 0);
    mMainForm.append(mMessageItem);
    mMainForm.addCommand(mExitCommand);
    mMainForm.addCommand(mConnectCommand);
    mMainForm.setCommandListener(this);
  }

  public void startApp() {
    mDisplay = Display.getDisplay(this);
    mDisplay.setCurrent(mMainForm);
  }

  public void pauseApp() {}

  public void destroyApp(boolean unconditional) {}

  public void commandAction(Command c, Displayable s) {
    if (c == mExitCommand)
      notifyDestroyed();
    else if (c == mConnectCommand) {
      Form waitForm = new Form("Waiting...");
      mDisplay.setCurrent(waitForm);
      Thread t =  new Thread() {
        public void run() {
          connect();
        }
      };
      t.start();
    }
  }

  private void connect() {
    HttpConnection hc = null;
    InputStream in = null;
    String url = getAppProperty("HitMIDlet.URL");

    try {
      hc = (HttpConnection)Connector.open(url);
      in = hc.openInputStream();

      int contentLength = (int)hc.getLength();
      byte[] raw = new byte[contentLength];
      int length = in.read(raw);

      in.close();
      hc.close();

      // Show the response to the user.
      String s = new String(raw, 0, length);
      mMessageItem.setText(s);
    }
    catch (IOException ioe) {
      mMessageItem.setText(ioe.toString());
    }
    mDisplay.setCurrent(mMainForm);
  }
}

and the servlet (HitServlet)

import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;

public class HitServlet extends HttpServlet {
  private int mCount;

  public void doGet(HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
    String message = "Hits: " + ++mCount;

    response.setContentType("text/plain");
    response.setContentLength(message.length());
    PrintWriter out = response.getWriter();
    out.println(message);
  }
}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:05:52+00:00Added an answer on May 15, 2026 at 11:05 pm

    Just let Eclipse generate the directory structure. Create two projects. One for J2ME as JavaME> MIDlet project (assuming that you’ve correctly installed the Mobile Tools plugin) and other for JavaEE as Web > Dynamic Web Project (assuming that you’re using Eclipse for Java EE and/or have installed Web Tools plugin separately). Run the J2ME project on the mobile client and run the JavaEE project on Tomcat server.

    See also:

    • Eclipse Mobile Tools documentation – Creating MIDlet project
    • Eclipse Web Tools documentation – Creating Dynamic Web project
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with a team using Eclipse to develop for android. We often
I am using eclipse to develop a web application. Just today I have updated
I am trying to develop a JSP application using Eclipse 3.6 Helios. Now I
I'm using MyEclipse to develop a really simple Java Struts project. Everything was working
I am working with Eclipse CDT and I want to build the current project
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
So working on getting my eclipse IDE going so I can develop my arduino
Someone must know of a working eclipse project for GWT / App Engine datastore
I'm using Eclipse to learn to develop Android applications in Java. I haven't used
For the project I am working on we need a mobile application and for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.