A problem with jdk 1.6

when I compile my java files, class file are produced after debbug.
but when i try to run my program (my class with main method ), I get this error message "error on thread main ...." .
so what can I do to run my classes?thanks for the help.
PS: I use command line on windows xp.

Hi,
I have such problem too.
With JRE under Windows.
Applets are executed properly.
But programmes for interpriter java.com
are compiled without errors but
are not work under JRE 1.6.
After:
java.com programme.class,
I get error message:
"Exception in thread "main" java.lang.NoClassDefFoundError: HelloJava/class".
for any programmes. Even for class with empty main function.
Second problem with compiler for Windows:
When source file programme.java
in UTF-8, the first symbol in file is spetial for unicode
files in Windows.
The compiler writes an error message and stops.

Similar Messages

  • Performance problems with jdk 1.5 on Linux plattform

    Performance problems with jdk 1.5 on Linux plattform
    (not tested on Windows, might be the same)
    After refactoring using the new features from java 1.5 I lost
    performance significantly:
    public Vector<unit> units;
    The new code:
    for (unit u: units) u.accumulate();
    runs more than 30% slower than the old code:
    for (int i = 0; i < units.size(); i++) units.elementAt(i).accumulate();
    I expected the opposite.
    Is there any information available that helps?

    Here's the complete benchmark code I used:package test;
    import java.text.NumberFormat;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.Vector;
    public class IterationPerformanceTest {
         private int m_size;
         public IterationPerformanceTest(int size) {
              m_size = size;
         public long getArrayForLoopDuration() {
              Integer[] testArray = new Integer[m_size];
              for (int item = 0; item < m_size; item++) {
                   testArray[item] = new Integer(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testArray[index]);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayForEachDuration() {
              Integer[] testArray = new Integer[m_size];
              for (int item = 0; item < m_size; item++) {
                   testArray[item] = new Integer(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testArray) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayListForLoopDuration() {
              ArrayList<Integer> testList = new ArrayList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testList.get(index));
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayListForEachDuration() {
              ArrayList<Integer> testList = new ArrayList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testList) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayListIteratorDuration() {
              ArrayList<Integer> testList = new ArrayList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              Iterator<Integer> iterator = testList.iterator();
              while(iterator.hasNext()) {
                   builder.append(iterator.next());
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getLinkedListForLoopDuration() {
              LinkedList<Integer> testList = new LinkedList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testList.get(index));
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getLinkedListForEachDuration() {
              LinkedList<Integer> testList = new LinkedList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testList) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getLinkedListIteratorDuration() {
              LinkedList<Integer> testList = new LinkedList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              Iterator<Integer> iterator = testList.iterator();
              while(iterator.hasNext()) {
                   builder.append(iterator.next());
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getVectorForLoopDuration() {
              Vector<Integer> testVector = new Vector<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testVector.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testVector.get(index));
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getVectorForEachDuration() {
              Vector<Integer> testVector = new Vector<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testVector.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testVector) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getVectorIteratorDuration() {
              Vector<Integer> testVector = new Vector<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testVector.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              Iterator<Integer> iterator = testVector.iterator();
              while(iterator.hasNext()) {
                   builder.append(iterator.next());
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
          * @param args
         public static void main(String[] args) {
              IterationPerformanceTest test = new IterationPerformanceTest(1000000);
              System.out.println("\n\nRESULTS:");
              long arrayForLoop = test.getArrayForLoopDuration();
              long arrayForEach = test.getArrayForEachDuration();
              long arrayListForLoop = test.getArrayListForLoopDuration();
              long arrayListForEach = test.getArrayListForEachDuration();
              long arrayListIterator = test.getArrayListIteratorDuration();
    //          long linkedListForLoop = test.getLinkedListForLoopDuration();
              long linkedListForEach = test.getLinkedListForEachDuration();
              long linkedListIterator = test.getLinkedListIteratorDuration();
              long vectorForLoop = test.getVectorForLoopDuration();
              long vectorForEach = test.getVectorForEachDuration();
              long vectorIterator = test.getVectorIteratorDuration();
              System.out.println("Array      for-loop: " + getPercentage(arrayForLoop, arrayForLoop) + "% ("+getDuration(arrayForLoop)+" sec)");
              System.out.println("Array      for-each: " + getPercentage(arrayForLoop, arrayForEach) + "% ("+getDuration(arrayForEach)+" sec)");
              System.out.println("ArrayList  for-loop: " + getPercentage(arrayForLoop, arrayListForLoop) + "% ("+getDuration(arrayListForLoop)+" sec)");
              System.out.println("ArrayList  for-each: " + getPercentage(arrayForLoop, arrayListForEach) + "% ("+getDuration(arrayListForEach)+" sec)");
              System.out.println("ArrayList  iterator: " + getPercentage(arrayForLoop, arrayListIterator) + "% ("+getDuration(arrayListIterator)+" sec)");
    //          System.out.println("LinkedList for-loop: " + getPercentage(arrayForLoop, linkedListForLoop) + "% ("+getDuration(linkedListForLoop)+" sec)");
              System.out.println("LinkedList for-each: " + getPercentage(arrayForLoop, linkedListForEach) + "% ("+getDuration(linkedListForEach)+" sec)");
              System.out.println("LinkedList iterator: " + getPercentage(arrayForLoop, linkedListIterator) + "% ("+getDuration(linkedListIterator)+" sec)");
              System.out.println("Vector     for-loop: " + getPercentage(arrayForLoop, vectorForLoop) + "% ("+getDuration(vectorForLoop)+" sec)");
              System.out.println("Vector     for-each: " + getPercentage(arrayForLoop, vectorForEach) + "% ("+getDuration(vectorForEach)+" sec)");
              System.out.println("Vector     iterator: " + getPercentage(arrayForLoop, vectorIterator) + "% ("+getDuration(vectorIterator)+" sec)");
         private static NumberFormat percentageFormat = NumberFormat.getInstance();
         static {
              percentageFormat.setMinimumIntegerDigits(3);
              percentageFormat.setMaximumIntegerDigits(3);
              percentageFormat.setMinimumFractionDigits(2);
              percentageFormat.setMaximumFractionDigits(2);
         private static String getPercentage(long base, long value) {
              double result = (double) value / (double) base;
              return percentageFormat.format(result * 100.0);
         private static NumberFormat durationFormat = NumberFormat.getInstance();
         static {
              durationFormat.setMinimumIntegerDigits(1);
              durationFormat.setMaximumIntegerDigits(1);
              durationFormat.setMinimumFractionDigits(4);
              durationFormat.setMaximumFractionDigits(4);
         private static String getDuration(long nanos) {
              double result = (double)nanos / (double)1000000000;
              return durationFormat.format(result);
    }

  • Memory problem with jdk/jre 1.1.8

    My name is BERGMANN Yannick.
    I'm working for IRM in Li?ge and we developped an application (user interface for an industrial measurement system) in Java (JDK/JRE version : 1.1.8).
    We have a big memory problem with this application :
    - This user interface is running on a WINDOWS NT PC with 128MB.
    - This is the command to lanch our application :
    C:\Program Files\JavaSoft\JRE\1.1\bin\jrew.exe" -ms32m -mx32m -cp "\Program Files\HMI\HMI.zip;\Velocis\Add_On\Jdbc\raima.jar;\Program Files\Swing-1.1.1\swingall.jar" be.irm.hmi.kernel.HMI -t15 -d"Velocis rdstcp" -newdb -mf1m -mr20
    - When our application is running, everything seems to be OK in memory for it. The garbage collector seems to work properly and our application has always at least 5MB free memory (We use the java instruction "Runtime.getRuntime().freeMemory()" to know this).
    - But when we look in the "Windows NT task manager" for the "jrew" application, the memory increases ALWAYS.
    - After 5 days our application is completely frozen and blocked ...???
    - here is a memory map of our Windows NT PC :
         "jre.exe"     "commit total"     "commit limit"     "commit peak"     "physical total"     "physical available"     "physical file cache"     
    Monday     92264     109256     194944     109424     130484     19492     6216     
    Thuesday     106196     123072     194944     123348     130484     6072     5840     
    Wednesday     110836     132288     194944     132416     130484     4408     5140     
    Thursday     108200     144980     194944     145140     130484     4888     5148     
    Friday     109440     158319     194944     161334     130484     4911     4992     
    Monday     111600     209060     228548     209148     130484     5184     3484     
    Have you any idea of what is happening with "jrew" in memory ?
    We have had this problem for six month and we are totaly out of idea.
    If you can give us any idea, we'll appreciate a lot.
    Thanks in advance,
    BERGMANN Yannick
    IRM SA - Software Engineer
    Tel. (32)4/239.90.10
    Tel. (32)4/239.90.74 (direct)
    Fax (32)4/263.40.97
    E-mail [email protected]

    We had a memory problem with a swing applet in our company. The major reason for this was that we added new components in a JTree and removed them later again, and the components we removed were never garbage collected. This was because with these components we added different listeners, and we didn't remove the listeners after we didn't need the components anymore. After we corrected this, the components where garbage collected.
    Perhaps it's a similar problem you have, or I have no idea. Check that you remove actionlisteners, mouselisteners etc from components you want to be garbage collected.
    You could also test your application with OptimizeIt to see what objects you create and how many you get of them over time: http://www.vmgear.com

  • Hangs up (problem with jdk?)

    Hi,
    we are developing an application using the Java API with Ifs 1.1.9 on Sun Solaris, Oracle 8.1.7.
    We parse files and an invoke perform some actions with the parsed data.
    Java Api and Parsing workd fine, until I encountered the following problem:
    In a certain function the action hangs up,
    meaning the function does not come to an end, after all I got a time-out from the ftp session.
    By debugging method I could identify that the hang up occurs within in the following step:
    Hashset hs = new HashSet();
    I changed the code to
    Vector v = new Vector();
    and got the same problem.
    Meaning that there might be a problem with the JDK-Library-Calls.
    When I call the same funtion with same argument from a JSP-Session, everything works fine.
    Is there anything known about that behavior?
    I have compiled the java-files on windows NT using an JDK1.3 installation and put it to the custum_classes directory on the sun machine.
    Might it be that I have to use jdk1.2.2.
    (for compilation?, for run-time on sun?)
    Help appreciated,
    Thomas

    Thanks for reply
    As suggested by you, i tried the 1.4.2_08 version, but i am facing the same kind of problems with this version also

  • SQL Developer 1.5 having problems with JDK 6 Update 7

    I tried to open a table using SQL Developer 1.5 but connection timed out. when using SQL developer 1.2 i don't get any problems opening it.
    i have JDK 6 update 7 installed.
    the only problem with SQL Developer 1.2 is that i get a jdbc in the error log
    how do i get to fix the SQL Developer 1.5?

    --The sql developer is connected using tnsnames.ora, with read only access
    --i'm using windows XP SP3
    --I have jdk 6 update 7 installed
    --The tables that I can't View is listed under Other Users.
    --I thought it was just because i have no permission to view it, but when i used the old sql developer 1.2, it displayed it properly.
    --The reason i want to use SQL developer 1.5 is because i don't want to see any JDBC error on log messages, which happens on the sql developer 1.2
    --i dont get to see any errors, sql developer suddenly can't view and lost the connection. it says connection is currently busy. and suddenly stops responding, the only way i can get it working again is by using the taskbar, when it close the program it gets java is not responding..
    --also when i try running sqlcli.bat i get error with it.. is it because of my java?
    --What more details do you need?
    Edited by: user10285639 on Oct 15, 2008 4:47 PM
    Edited by: user10285639 on Oct 15, 2008 4:53 PM

  • BC4J temporary focus problem with JDK 1.4.2

    Hello all,
    we have got a tricky problem with BC4J (Oracle JDeveloper 9.0.3.2)
    using the JDK 1.4.2 (Sun):
    There is a JFrame with a JMenuBar, containing a BC4J data panel with the controls on it.
    Now if one enters a value in a control and now directy clicks on the JMenuBar, the control
    gets a focusLost event but is not validated through BC4J and not set to the model.
    If a commit would be called from the menue the entered data is lost !
    In case of the JDK 1.3.1_02, which comes with the JDeveloper, everything works fine: after
    the focusLost event, the data is validated and set to the model.
    We have investigated the problem more deeper. The difference between
    the 1.4 and 1.3 is, that the 1.4 creates a temporary FocusEvent and the 1.3 not.
    We stepped up the stack into the Method oracle.jbo.uicli.jui.JUSVUpdateableFocusAdapter.focusLost:
    the temporary focusEvent causes this method to return and to do nothing:
    * Performs a setAttribute() on the control binding to save the changes made by
    * the control to the attribute value.
    public void focusLost(FocusEvent e)
    if (e.isTemporary())
    return;
    JUCtrlAttrsBinding binding = (JUCtrlAttrsBinding)mAttrBinding;
    I think it is a general problem with 1.4, because many things dealing with focus
    have been expaned and changed.
    Is this a bug or should BC4J not be used with 1.4 ?
    Greetings

    9.0.3.2 is not tested with JDK 1.4, so issues like this are not a surprise.
    However we will test this with our current development branch (which is being tested on JDK 1.4x) and verify if the behavior is reproducible.

  • EP 7.0 Install Problem with JDK path

    I’m having a problem with installing EP 7.0 on Solaris. We had Solaris 8 and then performed a fresh install of Solaris 10. Solaris 10 had Java 1.5. When performing the EP install at the step to supply the JDK directory message stating 1.5.0 was not supported. I had to install JDK from 1.4. family. I stopped the install and UNIX group installed 1.4.2_13.  I now receive message that directory /usr/bin is not a valid JDK directory:the java executable is missing. The UNIX team told me this is the valid directory path. I am not sure what the exact problem is. I stopped the install and provided the environment variable JAVA_HOME=/usr/bin and the same problem. Has anyone come across this problem maybe my version is not correct. Any ideas on what could be wrong are greatly appreciated.
    Thanks
    Martin

    Hi Martin,
    why are you pointing JAVA_HOME variable to /usr/bin.
    JAVA_HOME must always point to the directory where JAVA installation resides.So for you it might be /j2sdk1.4.2_13 if the JAVA installation directory is j2sdk1.4.2_13.
    If this does not solve ur problem.
    Please let me know the exact step where u r facing with the problem.
    Hope it helps
    Cheers,
    Santhosh

  • Problem with JDK 6 update 5 - Error Message says cant find java compiler

    Hi i am a complete beginner to programming and i am having trouble with the latest java development kit. jdk 6 update 5.
    The problem is i have set the path and the program cant find my compiler.
    I have installed the latest java development kit 6 update 5 on my windows xp machine.
    I have created a simple program as shown below:
    class Hello
         public static void main(String[] args)
                   System.out.println("Hello from java");
    saved the file to my desktop as Hello.java
    I have set the path variable like so:
    Go to control panel then click system icon then click advanced tab then click environmental variables.
    Now in system variables the path is shown as this - %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_05\bin;C:\Program Files\QuickTime\QTSystem\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\
    I then add this to the end;C:\Program Files\Java\jdk1.6.0_05\bin
    This is the location to the things like compiler, applet viewer etc.
    No in the command prompt i type javac Hello.java and i get this error message:
    C:\> javac Hello.java
    javac: file not found: Hello.java
    Usage: javac <options> <source files>
    use -help for a list of possible options
    The jdk is installed properly im sure but it can find my compiler.
    What mistake have i made in setting the path because im guessing that is related to the problem?
    Could someone out there please help me?
    Thank You
    Rafeeq

    saved the file to my desktop as Hello.java
    C:\> javac Hello.javaC:\ is not the desktop!
    The jdk is installed properly im sure but it can find my compiler.Of course it can! It just can't find the file you are trying to compile, because that's not in the root directory.
    I suggest you make a directory C:\java and save your source file there rather than on the desktop. In the command prompt, enter cd \java to make it the current working directory and then enter javac Hello.java.
    @Pravin: The question is about compiling, not running. CLASSPATH has nothing to do with this problem.
    db

  • Problems with JDK and NetBeans

    Hi, I've just started to learn java and I'm having some problems to compile projects. I installed JDK 1.5.0 (with NetBeans 4.0 beta 2), but when I try to compile any program (including the sample ones) I get the following error message:
    C:\Documents and Settings\F�bio\JavaApplication2\nbproject\build-impl.xml:34: java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
    Anyone knows what might be happening?
    By the way, I've already tried to reinstall the whole package (removing everything first), but it didn't help. Also, before installing this version I was using JDK 1.4.2 just fine, but now none will work .
    Thanks in advance

    I'll try that!
    By the way, I tried commenting out that line in the xml file and it worked! Still I have to do this to every new project I create, but it's a work-around =D
    Thanks for your help

  • Problems with jdk 1.4.2_03

    Hi, I know that this question has been made many times but I can't get solve my problem.
    I have jdk 1.4.2_03 and I'm using IE 6
    I have been reading "Getting started" tutorial and I can't see the applet , the java console sends a lot of errors:
    java.lang.NoClassDefFoundError: ParseException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    I configure:
    classpath and path.
    tools/internet options/advanced jvm and java(sun)
    java plug-in it's IE checked.
    All of them are correct.
    What can I do ??
    Please help meeeeee ......... : (

    Hi, I know that this question has been made many times
    but I can't get solve my problem.
    I have jdk 1.4.2_03 and I'm using IE 6
    All of them are correct.
    What can I do ??Maybe you could give some more information: which applet, did it compile (javac) without errors, did you put it in the right directory ?
    Mylene

  • Problem with jdk

    hi,
    im using j2sdk 1.4.2 with realJ as my IDE. the problem is that when i try to compile servlet codes with realJ, it shows errors when I import the servlet classes. eg:
    C:\Documents and Settings\kovenant\Desktop\servlet.java:2: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    any idea wats the problem?? thanx in advance

    Hi, I'm having the same package javax.servlet.http does not exist error. I've been reading past postings on the forum and tried the methods but none of them works.
    My code as follows:
    package Helpdesk;
    import javax.servlet.http.*;
    public class SessionCount implements HttpSessionListener
         private static int numberOfSessions = 0;
         public void sessionCreated (HttpSessionEvent evt)
              numberOfSessions++;
         public void sessionDestroyed (HttpSessionEvent evt)
              numberOfSessions--;
              return numberOfSessions;
    Error as follows
    C:\Program Files\Apache Group\Tomcat 4.1\webapps\g-megastore\src>javac SessionCount.java
    SessionCount.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    SessionCount.java:5: cannot resolve symbol
    symbol : class HttpSessionListener
    location: class Helpdesk.SessionCount
    public class SessionCount implements HttpSessionListener
    ^
    SessionCount.java:9: cannot resolve symbol
    symbol : class HttpSessionEvent
    location: class Helpdesk.SessionCount
    public void sessionCreated (HttpSessionEvent evt)
    ^
    SessionCount.java:14: cannot resolve symbol
    symbol : class HttpSessionEvent
    location: class Helpdesk.SessionCount
    public void sessionDestroyed (HttpSessionEvent evt)
    ^
    SessionCount.java:20: return outside method
    return numberOfSessions;
    ^
    5 errors
    My classpath is set as:
    set classpath=C:\Program Files\Apache Group\Tomcat 4.1\webapps\g-megastore\WEB-INF\classes
    both servlet.jar and j2ee.jar are in this \classes folder.
    What went wrong?

  • FocusEvent Problems with JDK 1.4.1

    I have a problem in my focus event.
    Under JDK 1.3 it runs under JDK 1.4.1_01 gives it problems.
    Here my method
    void jTextField1_focusLost(FocusEvent e)
    if( jTextField1.getText().equals(""))
    jTextField1.requestFocus();
    javax.swing.JOptionPane.showMessageDialog(null,"","Test",javax.swing.JOptionPane.OK_OPTION);
    else
    The window hangs.
    I think it is a bug in the JDK.
    I do not find a solution.
    Somebody can help me.

    First you set focus on the JTextField, then you show a dialog.
    This will not work the way you intend.
    Turn the order of the statements around and try again.
    Also, this is not the recommended way to validate input.
    Set an InputVerifier in your text field. That way the field cannot looses focus until the field is valid.

  • SunJCE TripleDES problem with JDK 1.6

    Hello All,
    If this has been answered in another post I am sorry I but couldn't find it. Ok, I am using the attched class to do TripleDES encryption and decryption. It works great in JDK1.4 and 1.5, but no go in 1.6. What has changed? I am on a project with right now uses 1.4 and I want to to be able to run on JRE 1.6 later without having to recompile. Why doesn't this work?
    I downloaded the SunJCE Unlimited Stringth policy files which fixed the key size issue I was getting, but now it's getting "Given final block not properly padded" when I try and decrypt my data that was originally encryoted using the 1.4 JRE.
    import java.io.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    public class Crypto
         Cipher ecipher;
         Cipher dcipher;
         // 8-byte Salt
         byte[] salt = {
         (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
         (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
         // Iteration count
         int iterationCount = 19;
         String Alg = "PBEWithMD5AndTripleDES";
         public Crypto(String passPhrase)
              try {
                   // Create the key
                   KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                   SecretKey key = SecretKeyFactory.getInstance(Alg).generateSecret(keySpec);
                   ecipher = Cipher.getInstance(key.getAlgorithm());
                   dcipher = Cipher.getInstance(key.getAlgorithm());
                   // Prepare the parameter to the ciphers
                   AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
                   // Create the ciphers
                   ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                   dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
              catch (java.security.InvalidAlgorithmParameterException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (java.security.spec.InvalidKeySpecException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (javax.crypto.NoSuchPaddingException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (java.security.NoSuchAlgorithmException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (java.security.InvalidKeyException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
         public String encrypt(String str)
              try
                   // Encode the string into bytes using utf-8
                   byte[] utf8 = str.getBytes("UTF8");
                   // Encrypt
                   byte[] enc = ecipher.doFinal(utf8);
                   // Encode bytes to base64 to get a string
                   String result = new sun.misc.BASE64Encoder().encode(enc);
                   return (result);
              } catch (javax.crypto.BadPaddingException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (IllegalBlockSizeException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (UnsupportedEncodingException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              } catch (java.io.IOException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              return null;
         public String decrypt(String str)
              try
                   // Decode base64 to get bytes
                   byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer((str));
                   // Decrypt
                   byte[] utf8 = dcipher.doFinal(dec);
                   // Convert to a string
                   String result = new String(utf8, "UTF8");
                   // Decode using utf-8
                   return result;
              catch (javax.crypto.BadPaddingException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              catch (IllegalBlockSizeException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              catch (UnsupportedEncodingException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              catch (java.io.IOException e)
                   System.err.println(e.getMessage()+"\n"+Functions.getStackTrace(e));
              return null;
    }any help woule be appreciated.
    thank you
    Tyson OSwald

    If you explicitly use "PBEWithMD5AndTripleDES"then
    it works OK. It is just the method call thatreturns
    the wrong string!I'm not sure what you are stating here, I am
    explicitly using PBEWithMD5AndTripleDES.No! You are usingecipher =
    Cipher.getInstance(key.getAlgorithm());and you should useecipher =
    Cipher.getInstance("PBEWithMD5AndTripleDES");or use the 'Alg' constant you have setup.Doh!, I see. It works now, thanks!
    >
    The problem is that key.getAlgorithm() should return
    "PBEWithMD5AndTripleDES" but will return
    "PBEWithMD5AndDES".
    Message was edited by:
    sabre150

  • Problem with JDK running

    I am relatively new to java programming and currently cannot get the
    jdk to run. I had the jdk working fine until last week when I reinstalled
    vista. I have changed the the environmental variable in the system properties to
    Class variable : c:\program files\java\jdk1.6.0_01\bin
    and I still get errors when trying to run one my java programs. The
    error I get is :
    Exception in thread "main" java.lang.NoClassDefFoundError: book
    What do I need to do to get java working again. Any help anyone
    can provide would be greatly appreciated.

    Please be very precise about what you are doing and what you have entered. There is no such thing as "Class Variable" that has anything to do with how Java finds classes.
    You need to set or specify the classpath. I recommend against setting it as an environment variable. The classpath is where Java looks for classes. C:\Program Files\Java\jdk1.6.0_01\bin is where Windows looks for the JDK executables, such as javac.exe and java.exe.
    You should specify the classpath using the -cp argument of both javac and java.
    The classpath needs to point to any directories containing your source code and/or class files, and also to any jar files needed by your application (if any).
    The classpath only needs to point to the top of the package hierarchy, if you are using packages for your Java classes (which you should for anything beyond a "Hello World" program).
    Finally, you need to be precise about case as well. Java expects a class called book to be in a file called book.class. However, conventionally, Java class names should start with a capital letter.
    For example, assuming you have a class Book in a package example and the code for your project is in C:\myproject\src, you would call :javac -cp C:\myproject\src C:\myproject\src\example\Book.javato compile your Book class, and thenjava -cp C:\myprojects\src example.Book to run it.

  • Font problems with RH 7.1 and JDK 1.3.1

    Hi there,
    I've read all post about this and looked at sun docs on how to add fonts. I've even replaced the fonts.properties with a new one I got from sun's page, but I can't make jdk 1.3.1 load the correct fonts for JDeveloper.
    Could anyone post here the steps to do it?
    I've also tried JDK 1.4.1 and for the moment everything works but some wizards, which I must run reverting to 1.3.1 JDK.
    Thanks,
    Ignacio

    To be honest, I managed to solve de problem getting the missing font from a Windows system (Ufffffff!!!!!). Now I don't get any font problems with JDK 1.3.1 but I find it very much slower than 1.4.1, and the problem is that JDeveloper wizards get weird in 1.4.1 and work OK in 1.3.1 ... let's hope Oracle releases a 1.4.1 ready JDeveloper soon.
    Thanks for your message.

Maybe you are looking for

  • IPod Touch 2G will not Sync. iTunes freezes. Help?

    Hi, I have an iPod Touch 2G and iTunes on 10.5.8. I cannot place the exact time things stopped syncing, but it was right around when I upgraded to OS 3 for the iPod, and installed iTunes 8.2. Subsequently, I have tried each version/update of iTunes t

  • Dual monitor for Power mac g5 dual 2.3ghz

    I wanted some advice on which monitors to get for a dual monitor setup and if its even possible to setup on my G5 or do I need a different video card? Here's my computer spechs: Power mac G5 dual core 2.3 ghz (late 2005) Model: A1177 Memory: 2GB DDR2

  • Conversion logic for the following!!

    Hi, Experts can you help me to build a conversion logic for the following 1.BKPF-BLART .setting it to 'ZF'. 2.BKPF-MONAT derived from  posting date 3.BKPF-WAERS set to GBP 4.Dr/.Cr indicator BSEG-SHKZG. If Posting Key (BSEG-BSCHL) is u201840u2019 the

  • Mail rules and iCloud

    Is there a way of copying mail rules in one mac to keep them alive on my macs after iCloud? I would appreciate any help, Thanks! Mario Lordeiro

  • Domino Lotus Mail Integration With Webcenter Spaces

    Hello, I am looking for solution for Domino Lotus Mail Integration with Webcenter Spaces, can you please let me know any one having any technical idea how to integrate with webcenter spaces. Please provide the solution. Thanks, Chandra