Runtime.class

3 views
Skip to first unread message

Maria Lemon Sjölander

unread,
Apr 14, 2011, 11:10:53 AM4/14/11
to Compiler construction 2011
I have a problem when running my generated .class file. Since the
Runtime.class is supposed to be in the lib folder how do I tell my
generated file or java where it is so it can use it? I have tried to
use the command:

java -classpath dir dir

But it dosen't like that my Runtime.class don't have a main method. I
am at the moment letting Runtime.class be in my src folder and it
works fine then. Anyone got a tip on how to solve this?

//Maria Lemón Sjölander

Rasmus Knutsson

unread,
Apr 14, 2011, 3:11:53 PM4/14/11
to Compiler construction 2011
Are you sure you have . in your classpath as well? the different
directories should be separated by :, as in java -cp lib:. Main.

On Apr 14, 5:10 pm, Maria Lemon Sjölander <maria.lemo...@gmail.com>
wrote:

Rasmus Knutsson

unread,
Apr 14, 2011, 3:14:23 PM4/14/11
to Compiler construction 2011
I mean the path to the java file of course: java -cp lib:<path> Main

Rasmus Knutsson

unread,
Apr 14, 2011, 3:20:28 PM4/14/11
to Compiler construction 2011
Sorry, that really didn't come out right. I mean the path to the
directory where you have your .class file. From your post it seems as
if you only left out the : though.

There really should be an edit function >.<

On Apr 14, 5:10 pm, Maria Lemon Sjölander <maria.lemo...@gmail.com>
wrote:

Maria Lemon Sjölander

unread,
Apr 15, 2011, 4:10:35 AM4/15/11
to Compiler construction 2011

I only get a NoClassDefFoundError on my generated .class file

java -cp ./lib/:../src/ $FILENAME

where $FILENAME = my generated .class files name like core001

Rasmus Knutsson

unread,
Apr 15, 2011, 5:00:49 AM4/15/11
to Compiler construction 2011
Your paths suggest that lib/ is a child, whereas src/ is a sibling of
the working directory. Is this correct? Perhaps you should give some
more information about the structure of your folders.

On Apr 15, 10:10 am, Maria Lemon Sjölander <maria.lemo...@gmail.com>
wrote:

Maria Lemon Sjölander

unread,
Apr 15, 2011, 5:08:11 AM4/15/11
to Compiler construction 2011
I got the same structure as you are supposed to have.

dir is the main directory with 3 subfolders; lib, src and doc. My
generated .class file ends up in src but the Runtime.class is in the
lib directory.

Rasmus Knutsson

unread,
Apr 15, 2011, 5:11:04 AM4/15/11
to Compiler construction 2011
The path ../src will take you first to your parent, and then to src.
Remove one dot.

On Apr 15, 11:08 am, Maria Lemon Sjölander <maria.lemo...@gmail.com>
wrote:

Maria Lemon Sjölander

unread,
Apr 15, 2011, 5:22:11 AM4/15/11
to Compiler construction 2011

Still the same error :/

Björn von Sydow

unread,
Apr 15, 2011, 6:58:56 AM4/15/11
to compiler-cons...@googlegroups.com
Hi,

the first thing to note is that the .class file (and the .j file) should end up in the same directory as the .jl file. So, your class file should NOT end upp in the src directory, unless the .jl file was also there.

In your example you seem to run the compiler from the main submission directory and have the coreXXX.jl also in this directory. Then the class file must be also in this directory.

The classpath must include the lib directory (to find Runtime.class) and the current directory (to find coreXXX.class). Thus the command could be

java -cp lib:. coreXXX

In general, I advice you to run the automatic tester; it will find the Runtime.class if it is in the lib directory and it will find your compiled class files if they are in the same directory as the source files.

Best regards

Björn

Reply all
Reply to author
Forward
0 new messages