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 / September 2007

Tip: Looking for answers? Try searching our database.

Netbeans/Cygwin/JDK issue

Thread view: 
saad - 26 Sep 2007 17:59 GMT
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.
saad - 26 Sep 2007 19:11 GMT
To add, first few lines of Simulator.java read:

package A.S;

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

import java.util.*;
import java.io.*;
Mark Space - 27 Sep 2007 05:26 GMT
> To add, first few lines of Simulator.java read:
>
[quoted text clipped - 5 lines]
> 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*
Lew - 27 Sep 2007 14:31 GMT
> 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.

Signature

Lew

Mark Space - 27 Sep 2007 19:43 GMT
>> 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.

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.
Lew - 27 Sep 2007 20:27 GMT
>>> 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)

> 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\:/.

Lew wrote:
>> For that matter, what makes you think the OP is even using Windows?

> 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.

Signature

Lew

David Zimmerman - 28 Sep 2007 16:07 GMT
>>>> To set the classpath, just add it to the existing CLASSPATH variable.
>>>
[quoted text clipped - 7 lines]
>
> Cygwin also allows the notation c\:/.

mkdir /c
mount c: /c

Tten you can refer to it as /c/... Makes life much easier
Lew - 29 Sep 2007 04:10 GMT
> 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.

Signature

Lew



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.