Author Topic: Why is slickedit not executing my class correctly?  (Read 4295 times)

afflictedd2

  • Guest
Why is slickedit not executing my class correctly?
« on: March 04, 2011, 04:55:30 AM »
why am I unable to run my java program correctly, this is what Slickedit
is doing which I don't understand:

java -classpath .;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip;C:\Program Files (x86)\GATE-6.0\lib\*;C:\Program Files (x86)\GATE-6.0\bin\gate.jar;classes\;C:\Users\UNST\lb1\StandAloneAnnie\ StandAloneAnnie
java.lang.NoClassDefFoundError: Files
Caused by: java.lang.ClassNotFoundException: Files
   at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Files.  Program will exit.
Exception in thread "main"

I have told it my main class is: StandAloneAnnie and added my windows Classpath to
the Classpath in the project properties.

Just to add, it runs correctly from the commandline when I execute:
java StandAloneAnnie

Any help appreciated,

Ted
« Last Edit: March 04, 2011, 06:36:57 PM by afflictedd2 »

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: Why is slickedit not executing my class correctly?
« Reply #1 on: March 09, 2011, 04:45:40 PM »
Can you provide the Help > About SlickEdit information? Feel free to redact anything you don't want to share.

I just tested this with v15.0.1.3 with hot fix 19 applied and it works fine for me. I used a workspace with a typical "Hello world" program and made the following changes to run a different program. Normally, if you create a Java workspace/project, you don't have to set either of these.
1) Set the Classpath -- select Build > Java Options and click on the Classpath tab. Click the "Add Path" button and navigate to the directory containing the .class files you wish to run.
2) Set the Main class: click on the JRE tab and type the name of the main class in the "Main class" field.

Here's my normal process for setting up a Java workspace/project:
1) Select Project > New to bring up the New dialog.
2) Select the "Project type". I typically use "Java - Empty Project" if I have existing code. If I'm starting a project from scratch, I typically use "Java - With main()".
3) Enter the name of the project in "Project name". The name you specify will also be the default name for the main class. If you are setting up a project for existing code, you can enter the name of the existing main class.
4) I typically want SlickEdit to create a new folder by that name, so I check "Create project directory from project name". If you are setting up a project for existing source, then you can elect to create a new folder and copy the source there; or you can uncheck this and use an existing directory.
5) Choose the location for this new folder. If you are setting up a project for existing code, select the root of the source tree for this directory. You can also have SlickEdit store it's files separately from the source files. In that case, specify the name of the folder for the SlickEdit files. Later, when you add files to the project you can specify a different location for the source files.
6) Confirm the location under "Files will be located at" and make any changes needed.
7) Leave "Create new workspace" selected.
8 ) Click "OK".

SlickEdit creates the directory and puts in the following things:
1) Project file ending in .vpj.
2) Workspace file ending in .vpw.
3) A history file ending in .vpwhist.
4) A tag file ending in .vtg.
5) If I chose the project type with main(), a java file named after the project name I gave.

That directory is the root of the source hierarchy. If I'm setting up a workspace/project for an existing codebase, I'll either copy the codebase to this directory or have selected the appropriate directory when I created the project. At this point, you should be able to select Build > Build or Build > Rebuild to do a build and Build > Execute to run the program.

You do not need to specify the main or the classpath for this unless the main class does not match the name entered for "Project name" or the location of the source files is not where the project file was created. This would be the case if you are trying to keep the SlickEdit files separate from the source, which is common in a mixed tool environment so that tool-specific files do not pollute the source hierarchy.

Let us know if this helps.





Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 77
Re: Why is slickedit not executing my class correctly?
« Reply #2 on: March 09, 2011, 04:59:45 PM »
I'm pretty sure the problem is that there are no quotes around the classpath in that execute line:

Quote
java -classpath .;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip;C:\Program Files (x86)\GATE-6.0\lib\*;C:\Program Files (x86)\GATE-6.0\bin\gate.jar;classes\;C:\Users\UNST\lb1\StandAloneAnnie\ StandAloneAnnie

You have a path with spaces in there (C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip), and it is not surrounded with quotes, so java is trying to execute the class Files...which is just it's way of incorrectly parsing the classpath argument because there are no spaces around Program Files.

How did you add all the Classpath elements to your project at Project Properties?  Can you undo that, and instead go to Build > Java Options > Classpath, and add them there?  Then try to Build and Execute.  Any luck?

- Ryan