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

Unable to run java program


My lecturer has given us a sample java program which consists of three java files.
1) Create.java
2) Record.java
3) Enrol.java

As instructed by her, we have to do the following steps:
Compile Record.java
Compile Create.java
Run Create.java
Run Entrol.java

However, I encountered errors when running Enrol.java. Can someone please help? I would very much like to seek help from her but as my course is a part-time basis, the earliest date i can see her is next week.

Please advise. The sample files are found at http://test.swenlee.com/java.html
1 Solution
Could you paste the exception that are you getting?
Gibu GeorgeChief Technology OfficerCommented:
Is it giving NoClassDefFound?, then set the classpath to ccurrent directory

java -cp . Create
java -cp . Enrol
i suppose, the instructions must be:
Compile Record.java
Compile Create.java
!  Compile Enrol.java
Run Create.java
Run Enrol.java
This is what you need to do :

Copy all the java files and put them in a single directory (leave thenm if they already are)

Open command prompt and go to the directory - at the prompt, do this

javac *.java

---This will result in all the class files being generated

--Now to run Create

java -classpath . Create

-- To run Enrol

java -classpath . Enrol

See the '.' in the command - its for setting the classpath to current directory so that java knows where to pick up the class files from.
dandeliondreamAuthor Commented:
Thanks arioh for your comments. It works now!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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