[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3551
  • Last Modified:

Cannot find Main Class in Eclipse

1.      I am using Eclipse 3.4.2, Oracle Thin Client OC4J Standalone Server 10.1.3.n
2.      I right-click my project (a Dynamic Web Application with .jsp and java classes)
3.      I select Run As/Run On Server
4.      I choose an existing server localhost/Oracle OC4J Standalone Server 10.1.3.n at local host
5.      I click Next
6.      I see that the project is in Configured projects
7.      I click Finish

I get the message from Java Virtual Machine Launcher. "Could not find the main class. Program will exit."

I have googled and looked on Experts-Exchange but to no avail.

When I go to Properties, Java Build Path I see the error Project X cannot reference itself  It seems probable that this is part of the problem&
  • 7
  • 6
1 Solution
Are you able to start the server from the Eclipse "Servers" window without any deployed web application? This sounds like you haven't a correctly configured server descriptor as far as Eclipse is concerned.

Is this an OC4J specific project, or is it standard Java web app that you can try to deploy in Tomcat?
Try this in Eclipse

1) Download the latest standalone OC4J, unzip to C:\OC4J


2) In Eclipse: Window -> Preferences -> Server -> Runtime Environments -> Add
Choose Oracle -> Oracle OC4J Standalone 10.1.3.n -> Next
Choose Default JRE
For the OC4J J2EE home, use browse to C:\OC4J\j2ee\home

3) In Server's tab, right clock, New -> Server, choose Oracle OC4J Standalone 10.1.3.n, add the project,

Before starting from Eclipse, start from command line:

set OC4J_HOME=C:\oc4j\j2ee\home
set ORACLE_HOME=C:\oc4j
set JAVA_HOME=... path to your JDK...

cd \oc4j\bin
oc4j -start

Enter your new admin password ("admin")
Then CTRL-C to shutdown

Then go to Eclipse and start the OC4J from the Server's tab, if that works, then move on to attempt to deploy a web app to it. This works for me except I have not deployed an app to the container.

Other references that might help:
gordontmAuthor Commented:
Hi mrjoltcola

Thank you very much for replying and for your very detailed instructions!

I am following your instructions dilligently and am in step 3.

However there are all sorts of .jars that are missing from the classpath.  I have copied and pasted about twenty so far, but now I am stuck.  

Eclipse asks for  Missing classpath entry C:\oracle\oc4j10.1.3.4\j2ee\home\..\..\lib\xmlparserv2.jar
and unfortunately it doesn't specify what the directories are between home and lib, but just writes \...\...

I have tried to google "default directory xmlparserv2.jar" but I do not seem to be able to know where to put xmlparserv2.jar

Do you have any ideas?

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Were you able to create an OC4J server in step 2, using the 10.1.3.n ? You browsed to the correct directory?

You should not need to copy any jars to setup the server with Eclipse Ganymede, I did it with no add-ins.

What JDK/JRE have you installed?

Perhaps also moving this to the Java zone would help.
gordontmAuthor Commented:
1. Hi. See the first picture.  When I press [Next] I get the second picture
2. Please note I still have the problem "Project 'X' cannot reference itself".  Maybe this is part of the problem
3. JDK is either j2sdk1.4.2_12 or j2sdk1.4.2_13 or j2sdk1.4.2_05.  [I am a little confused about this last point]

Thanks very much!

I recommend installing a 1.5 JDK (since OC4J claims it can support 1.4.2 or 5.0)
I am using Java 5 and 6, haven't used 1.4 in yrs.

Try configuring the new JDK as your standard Eclipse JDK, then try it all over.
gordontmAuthor Commented:
I have downloaded jdk-1_5_0_18-windows-amd64.exe
[I will be unable to use this in the long term because the live application using 1.4] but I will try here locally on my laptop to see if I can get it working.

I right-clicked the JRE System Library [j2sdk1.4.2_12] and tried to change it to alternate JRE / JRE1.6.05 but it complains that "Application of the classpath container changes failed. Project "X' can not reference itself."

JRE 1.6 is Java 6, not 5, so you have 3 versions in your environment you area dealing with.

Sorry, I have no other suggestions. I only use Java 5 & 6, and really don't use OC4J much anymore either. I recommend posting to Java zone as well, you can add the zone to your question.
gordontmAuthor Commented:
Thank you very much for trying mrjoltcola.  Thank you for your suggestion about java zone. I will try and move it.
gordontmAuthor Commented:
Hi mrjoltcola.  I managed to follow all your instructions.
Basically the problem was that somehow my project referenced itself in the Web App Folders. Once I got rid of this, then everything was a breeze.

I will now give you the points as you answered my question!.  However the application is still not working... When I go to Servers, the application is started  (see picture below) but when I go to http://localhost:8888/charm/  it doesn't work.  I will open another question, could you have a look at it?

Make sure to post in Java, Eclipse and Web app servers if possible. Post a link back to this one in case anyone needs some background. Not being an OC4J guru, I probably cannot help much more except to just try it myself. I will look in on the question and contribute if possible.

gordontmAuthor Commented:
OK. Thanks for advice.
I put it in Java, Eclipse and Oracle [before reading your comment]
If no-one answers I will ask an administrator to move it to Web App. [its not possible to move once zones have been assigned]
Use request attention for an admin's help

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now