Top.Mail.Ru
August 22nd, 2007 - Java developers — LiveJournal
? ?

Java developers

August 22nd, 2007

06:25 pm - oracular_rufio - JDK in Fedora Core 5

The computer science department at my university does all of their core courses in Java, which is good for me in some ways because I'm used to C++. However, they also insist on using Eclipse, and I don't know whether it's because my computer is six years old or because Eclipse is so damn huge, but it takes about three hours to get its context menus figured out, and thus is impossible for writing code in. Since I write everything else I do in vim and compile at the command line anyway, I'd just as soon do that with Java. So at the beginning of the summer, I downloaded and installed the latest JDK. Now, it compiles things just fine, but attempting to run the compiled programs results in this error:

Exception in thread "main" java.lang.NoClassDefFoundError: MyClass.class
at gnu.java.lang.MainThread.run(libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: MyClass.class not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.ClassLoader.loadClass(libgcj.so.7)
at java.lang.Class.forName(libgcj.so.7)
at gnu.java.lang.MainThread.run(libgcj.so.7)


Part II:
I can compile junit tests with junit imports in them, by using -classpath path/to/junit/jar/file, but they encounter the same problems when I try to run them. However, my professor told me that the way I need to compile junit tests with JDK is to compile it with another file with the text:

import junit.textui.TestRunner.*;

public class RunTestMyClass {
public static void main (String [] args) {
junit.textui.TestRunner.run (TestMyClass.class);
}
}


Trying to compile this results in some error message to effect that it can't figure out what this "TestRunner" thing is, even though it seems to have figured out that it's in the junit.textui file.

Can anyone tell me how to make this work on my machine?

10:48 pm - robinfivewords - Performing lookups (like Excel) in Java

Please forgive this beginner's question, but I can't find a single code example via Google. Can someone direct me to an example of Java code that performs a simple lookup function like VLOOKUP in Microsoft Excel?

I want to effectively transform a String array into an int array by "looking up" the first character of each element of the String array against a static array/table. In Excel I would do this with a very simple formula like this:

=VLOOKUP(LEFT(A2,1),$F$2:$G$14,2,FALSE)

So in column B, calculated via this formula, I would have the int value that each String value in column A was transformed into. Column B is the new array I want to create. Simple, right?

I've tried to use a series of for loops and if statements to compare each String value in the original array with each of the values in the lookup array, but what ends up happening is that a two String values that I think should be equal are not evaluated as equal, so the lookups always fail and the new array stays at all-zeroes.

Thanks to anyone that can help!
Powered by LiveJournal.com