Netbeans/Cygwin/JDK issue

S

saad

I am working on a project, and one module of the project
is written by a person in JAVA who passed away couple of months ago in
an accident.
Most of my work is in C/C++ though this module is in JAVA and I need
to manipulate
input and output of this work for my project, without going into
details of whats running inside, though,
if I get some control on that as well, thats a plus.
Now here is what I have already done.

Being a novice to JAVA, i installed latest JDK+Netbeans bundle
available.
Netbeans appears working perfectly fine (compiles and executing a
Hellow World :p )

Here is the issue I am having.

The author of the work has given instructions to run the project. He
has both .java and .class
files included. Here is the directory structure.



A
|
->C
|
->P
|
->S

Both C and S have .java (and corresp .class) files.
According to the documentation, to run the project, i should go to
S and run following script:

-classpath Give_your_own_path_here(like /c/java/a/) A.S.Simulator $1
$2 $3


$1 $2 $3 appear to be some input variables i think.
Simulator file is in S (both .class and .java)
This script is in a file called startA.
On command line, I type ./startA while standing at S, and it gives me
this error:

java.lang.NoClassDefFoundError: A/S/Simulator
Exception in thread "main"

Can you guide me on cygwin part?
PS: My jdk is in another directory

Q2
============
How to I run this Simulator thing in NetBeans. How to create a project
such that all source files are included and build them to get a
running project.
NetBeans appears to me an easier GUI based route, but, since I am very
novice,
no clue where to start on it. This is kinda urgent as I need to show
this thing running to someone
tomorrow.

PS: I have experience in Visual C++ and know how to create projects n
stuff.
 
S

saad

To add, first few lines of Simulator.java read:

package A.S;

import A.C.*;
import A.P.*;

import java.util.*;
import java.io.*;
 
M

Mark Space

saad said:
To add, first few lines of Simulator.java read:

package A.S;

import A.C.*;
import A.P.*;

import java.util.*;
import java.io.*;

and this file also has a method with this signature:

public class Simulator {

public static void main ( String [] args )
{
// ...
}
}

That's where things start. Check to make sure you are running the
correct file. You could also look at args to see how %1 %2 %3 are used.

To set the classpath, just add it to the existing CLASSPATH variable.
For example:

c:\my\stuff\A\S\Simulator.class
CLASSPATH=c:\my\stuff

The java command should now recognize A\S as corresponding to the
package A.S and find the Simulator.class file.

(For Cygwin, I guess you'd use your example and set CLASSPATH=/c/java)

If your problem is that you added an extra /a on the end, this is pretty
remedial. Better go read up on Java or you're going to have a very
tough time. The Sun tutorial is good.

I'd use the CLASSPATH because -cp over-rides your existing classpath.
The -cp switch works for simple self-contained programs but may not work
if there are extra .jar's or other .class files that are needed
elsewhere on the disk. It's easiest to set CLASSPATH from the Control
Panel, imo. Just add ;c:\my\stuff to the end of the CLASSPATH variable
and you should be ok.

For the NetBeans thing... New Project->General->Java Project with
Existing Sources. *coughRTFMcough*
 
L

Lew

Mark said:
To set the classpath, just add it to the existing CLASSPATH variable.
(For Cygwin, I guess you'd use your example and set CLASSPATH=/c/java)

Why in the world would you assume that? That is very dangerous.

You do realize that using Cygwin, or Windows without Cygwin, one can install
the JDK anywhere they please, and need not install only one JDK, don't you?
For that matter, what makes you think the OP is even using Windows?
I'd use the CLASSPATH because -cp over-rides your existing classpath.
The -cp switch works for simple self-contained programs but may not work
if there are extra .jar's or other .class files that are needed
elsewhere on the disk. It's easiest to set CLASSPATH from the Control
Panel, imo. Just add ;c:\my\stuff to the end of the CLASSPATH variable
and you should be ok.

This is backwards. Use the -cp (-classpath) option because CLASSPATH is
global and might not apply equally well to all your projects. -cp is
guaranteed to be correct for a given run.

Use -cp (-classpath); don't use CLASSPATH in most cases.
 
M

Mark Space

Lew said:
Why in the world would you assume that? That is very dangerous.

I'm not sure of your point. The OP gave an example of using /c/java/a
as a classpath. I assumed the extra /a was his issue.
You do realize that using Cygwin, or Windows without Cygwin, one can
install the JDK anywhere they please, and need not install only one JDK,
don't you? For that matter, what makes you think the OP is even using
Windows?

Well for the last question Cygwin is expressly for users on Windows. If
he's running *nix or Solaris or a Mac, why would he need Cygwin? ;-)

For me, it's more convenient to set the system CLASSPATH once, and not
mess with it again. If you are running more complicated set-ups which
require different .jars for different versions of JDK and project, I can
see that this would be rather inconvenient and setting the class search
path for each project might be better.
 
L

Lew

I'm not sure of your point. The OP gave an example of using /c/java/a
as a classpath. I assumed the extra /a was his issue.

Cygwin drives have the format /cygdrive/c/, not merely /c/. /c/ would map to
%CYGWIN_INSTALL_DIR%/c/, not C:/.

Cygwin also allows the notation c\:/.

Mark said:
If he's running *nix or Solaris or a Mac, why would he need Cygwin? ;-)

You are right. I missed the part of the original message that said:
Can you guide me on cygwin [sic] part?

That's not the only mistake I made in my post, but I have enough ego not to
point out any more.
For me, it's more convenient to set the system CLASSPATH once, and not mess with it again. If you are running more complicated set-ups which require different .jars for different versions of JDK and project, I can see that this would be rather inconvenient and setting the class search path for each project might be better.

I usually work on multiple projects, not all of which use the exact same
libraries. A global CLASSPATH is useless to me.

I see how it would work for other scenarios, though.

My only issue there is that CLASSPATH is extrinsic to the compilation command
and therefore harder by a skootch to track. The -cp option is right there in
the compilation command (or Ant script) where you can't miss it.

A similar argument pertains to putting libs in the shared/ (or equivalent)
library of an application server vs. in the application-specific lib/ folder.
 
D

David Zimmerman

Lew said:
Cygwin drives have the format /cygdrive/c/, not merely /c/. /c/ would
map to %CYGWIN_INSTALL_DIR%/c/, not C:/.

Cygwin also allows the notation c\:/.

mkdir /c
mount c: /c

Tten you can refer to it as /c/... Makes life much easier
 
L

Lew

David said:
mkdir /c
mount c: /c

I see. Nice - I've never thought of that and I've been using Cygwin for years.

I can only hope to remove my foot from my mouth by changing my opinion rapidly
once I understand the facts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,049
Members
48,769
Latest member
Clifft

Latest Threads

Top