473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Java user class directory not found

I have a problem with Java finding my custom class directory. I have searched the forums and tried everything, but nothing seems to work. The <javapgm>.java compiled cleanly and created <javapgm>.class. Error message is:

Warning: java.lang.ClassNotFoundException: javapgm

Versions of software:

Apache 2.0.59(Win32)
PHP 4.4.4
Java 1.5.0_01
Windows 2000 5.0

In my application, PHP displays a screen, data is entered, and the above error occurs. I swapped out my custom Java class for an example I found on the internet:

$system = new Java("java.lang.System");
print "Java version=".$system->getProperty("java.version")." <br>\n";
print "Java vendor=".$system->getProperty("java.vendor")." <p>\n\n";
print "OS=".$system->getProperty("os.name")." ".
$system->getProperty("os.version")." on ".
$system->getProperty("os.arch")." <br>\n";

$formatter = new Java("java.text.SimpleDateFormat","EEEE,
MMMM dd, yyyy 'at' h:mm:ss a zzzz");
print $formatter->format(new Java("java.util.Date"))."\n";

and it properly works and displays:

Java version=1.5.0_01
Java vendor=Sun Microsystems Inc.
OS=Windows 2000 5.0 on x86
Friday, July 20, 2007 at 9:33:06 AM GMT-07:00

I found the documentation regarding the difference between accessing user classes, java extension classes and bootstrap classes, then added my custom class directory (user class) to the php.ini file after java.class.path=:

java.class.path= "c:\php\extensions\php_java.jar; c:\www\slfsrvmar\javaclasses"
java.library.path = "c:\php\extensions; "c:\jdk\jdk1.5.0_01\jre\lib"
java.home = "c:\jdk\jdk1.5.0_01\bin"
java.library = "c:\jdk\jdk1.5.0_01\jre\bin\client\jvm.dll"

I tried swapping the order of the two directories in java.class.path. My custom class still did not work and neither did the getPropriety test, above. The second directory in the concatenation does not seem to be recognized (yes, it's typed correctly). Note, that Apache was stopped/started each time when php.ini was changed and a new browser window was also opened after each Apache cycling.

I then found a java method to change the directory thinking that might be the solution:

$system = new Java("java.lang.System");
print "java.class.path BEFORE=".$system->getProperty("java.class.path")." <br>\n";
$system->setProperty("java.class.path", "c:\\www\\slfsrvmar\\javaclasses");
print "AFTER path change=".$system->getProperty("java.class.path")." <br>\n";

which produced:

java.class.path BEFORE=c:\php\extensions\php_java.jar; c:\www\slfsrvmar\javaclasses AFTER path change=c:\www\slfsrvmar\javaclasses

My class was still not found.

Then modified WINNT environment variable CLASSPATH and added c:\www\slfsrvmar\javaclasses. Rebooted and still the same problem.

I am totally mystified as to what to do next. The PHP/Java interface seems to be working or the Java version and today’s date display would not function.

Any help will be most appreciated. I’m quite new to Java.

Thanks, MAR
Jul 20 '07 #1
1 3849
prometheuzz
197 Expert 100+
Well I have no experience with PHP, but you're warm about the CLASSPATH there: if a class file compiles but doen't run (throws a NoClassDefFoundError) then there's something wrong with the CLASSPATH.

Just a shot in the dark, but maybe that space is messing things up?
Expand|Select|Wrap|Line Numbers
  1. java.class.path= "c:\php\extensions\php_java.jar; c:\www\slfsrvmar\javaclasses"
  2.                                                  ^
  3.                                                  !
Jul 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Lem | last post by:
I get the error Exception in thread "main" java.lang.NoClassDefFoundError when I type java app2 in the command prompt. I've tried moving to the jre directory and typed java c:\app2\app2, but it...
3
by: Larry Martin | last post by:
I am trying to run a Java Applet on my ascx page and am getting an IO exception when IE6 tries to load the applet. It seems a lot of others are getting the same problem but a search of the web did...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
9
by: IchBin | last post by:
I am trying to get Java to work from within PHP. I have been looking at: http://us2.php.net/java The error and line of PHP code: $system = new Java('java.lang.System'); Fatal error: Class...
2
by: pinkf24 | last post by:
I cannot figure out how to add the following: Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.