Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Compiling .java files

Thread view: 
peddie - 21 Mar 2006 17:26 GMT
Hi
I have a java file that I compiled and when used it in an application,
an error said that I could not call the class since it is not public.
Then I noticed that the some codes are declared as private, so I
changed them all to public then recompile. The error message still
persits that it is not public.

Did I do this right? Do I have to do something extra before
re-compiling the java file?

Am so new to this subject please kindly assist me

Thanks

Peddie
Lord0 - 21 Mar 2006 17:32 GMT
It is the norm to post the offending code.

Lord0
peddie - 21 Mar 2006 17:44 GMT
I tried to instantiate the java object inside a PeopleSoft application.
The error is a message box below.

Java Exception: java.lang.NoClassDefFoundError: finding class
PhoneticEye

I save the .class files in C:/Pt8.44/class/ which I have added this in
the CLASSPATH.

The java file that I compilied is below

public class PhoneticEye {

   static {
       System.loadLibrary( "PhoneticEye_jni" );
   };

   /**Native Method Definition*/
   public static native void PE_Initialize();
   public static native void PE_UnInitialize();
   public static native void PE_SetThreshold( int threshold );
   public static native String PE_GetSmartCode( String targetStr, int
mode );
   public static native String[] PE_GetPhonemes( String targetStr, int
mode );

   public static native int PE_Match_Str2Str( String matchStr, String
targetStr, int type, int mode );
   public static native int PE_Match_Ph2Str( String[] phonemes, int
phonemesSize, String targetStr, int type, int mode );
   public static native int PE_Match_Ph2Ph( String[] matchPhonemes,
int matchPhSize, String[] targetPhonemes, int targetPhSize, int type,
int mode );
   public static native StringMatch[] PE_Match_Str2List( String
matchStr, String[] targetStrList, int listSize, int type, int mode );

   // PE MODES
   public static final int PE_MODE_ENGLISH = 0;
   public static final int PE_MODE_NONENGLISH = 1;

   // PE TYPES
    public static final int PE_TYPE_OR = 0;
   public static final int PE_TYPE_AND = 1;
   public static final int PE_TYPE_AND_TRANSPOSED = 2;
   public static final int PE_TYPE_EXACT = 3;

   PhoneticEye() {}

   void Initialize() {
       PE_Initialize();
   }

   void UnInitialize() {
       PE_UnInitialize();
   }

   void SetThreshold( int threshold ) {
       PE_SetThreshold( threshold );
   }

   String GetPESmartCode( String targetStr, int mode ) {
       return PE_GetSmartCode( targetStr, mode );
   }

   String[] GetPhonemes( String targetStr, int mode ) {
       return PE_GetPhonemes( targetStr, mode );
   }

   int Match_Str2Str( String matchStr, String targetStr, int type, int
mode ) {
       return PE_Match_Str2Str( matchStr, targetStr, type, mode );
   }

   int Match_Ph2Str( String[] phonemes, String targetStr, int type,
int mode ) {
       return PE_Match_Ph2Str( phonemes, phonemes.length, targetStr,
type, mode );
   }

   int Match_Ph2Ph( String[] matchPhonemes, String[] targetPhonemes,
int type, int mode ) {
       return PE_Match_Ph2Ph( matchPhonemes, matchPhonemes.length,
targetPhonemes, targetPhonemes.length, type, mode );
   }

   StringMatch[] Match_Str2List( String matchStr, String[]
targetStrList, int type, int mode ) {
       return PE_Match_Str2List( matchStr, targetStrList,
targetStrList.length, type, mode );
   }

}

class StringMatch {
   public String targetStr;
   public int simValue;
   public StringMatch(){
       targetStr = "";
       simValue = 0;
   }
}
Oliver Wong - 21 Mar 2006 17:46 GMT
> Hi
> I have a java file that I compiled and when used it in an application,
[quoted text clipped - 9 lines]
>
> Thanks

   Is the class itself declared public?

<code>
public class Foo {
 private int x;
}
</code>

In this example code I just posted, the class itself, Foo, is public, even
though one of its fields, x, is private.

   You also have to make sure that the name of the class is the same as the
name of the file, with the extra ".java" extension. So you MUST save the
above code in a file called "Foo.java" to compile it. If you name it
something else, like "Bar.java", it won't compile properly.

   - Oliver
youri lima - 21 Mar 2006 18:02 GMT
Java Exception: java.lang.NoClassDefFoundError: finding class
PhoneticEye

this error is the wrong filename error because when calling a class it
searches for files with that name before actually looking in the file
Roedy Green - 21 Mar 2006 18:45 GMT
>NoClassDefFoundError

see http://mindprod.com/jgloss/caq.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

youri lima - 21 Mar 2006 21:08 GMT
Java Exception: java.lang.NoClassDefFoundError: finding class
PhoneticEye

this error is the wrong filename error because when calling a class it
searches for files with that name before actually looking in the file
peddie - 06 Apr 2006 18:49 GMT
Hi Oliver
The name is all the same. In fact I have downloaded these files from
PhoneticEye website (the supplier that provides the fuzzy search
facility). I try to use this on PeopleSoft application.
The class called PhoneticEye and all relevant files too.
So with your theory, tho the fields are private, this should work then
but I dont know why it didnt work.

Now I try to compile the java file with command line. It gives me the
error Exception in thread "main" java.lang.NoClassDefFoundError:
PhoneticEye/Java

If I use javac command line it didnt give me an error message and a
class file is created. Whats the difference between java and javac?
Thanks a lot
Peddie
Oliver Wong - 06 Apr 2006 20:18 GMT
> Hi Oliver
> The name is all the same. In fact I have downloaded these files from
[quoted text clipped - 12 lines]
> Thanks a lot
> Peddie

"javac" is the program which compiles a java programs, while "java" is the
program which actually runs the program. If the file ends in ".java", it's
probably a java source code file, which is intended to be read by humans and
not by computers. If the file ends in ".class", it's probably a java class
file, which is intended ot be run by computers and not read by humans.

   So the appropriate steps are:

(*) Download the ".java" file from the website.
(*) Optionally inspect them and make modifications to them if you want.
(*) Run "javac" on the ".java" file to generate a ".class" file.
(*) Run "java" on the ".class" file to actually run the program.

In that last step, when you run "java", make sure not to include the
".class" extension. So if you wanted to run the program in the file
"Foo.class", you would type in "java Foo", and not "java Foo.class".

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.