Bug 361737 - Run as Java Application and Run as JUnit Test crash with java.lang.NoClassDefFoundError if project name contains a colon
Summary: Run as Java Application and Run as JUnit Test crash with java.lang.NoClassDef...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.8   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: readme
: 287867 413078 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-22 18:59 EDT by Juho Autio CLA
Modified: 2020-04-16 13:39 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juho Autio CLA 2011-10-22 18:59:45 EDT
Build Identifier: 20110916-0149

If a Java project name contains a colon (":"), the project is successfully built ie. .class files are generated under the output folder (bin/ for example), but any attempt to execute some run configuration ('Run as Java Application' or 'Run as JUnit Test' for example) crash with java.lang.NoClassDefFoundError.

Work-around is to not use project names with colon, but some project types are named to include a colon by convention.

Reproducible: Always

Steps to Reproduce:
1. Create a new Java project and name it as 'problematic-test:project'
2. Create a new JUnit Test Case
3. Run the Test: you should get java.lang.NoClassDefFoundError with a stacktrace into the console
4. Rename the project to 'test-project'
5. Run the Test again: it should now run ok.
Comment 1 Ayushman Jain CLA 2011-10-24 02:40:40 EDT
How did you create a java project with a colon in the name? Eclipse doesn't allow it and gives ": is an invalid character in resource name 'problem-test:project'" error.
Comment 2 Juho Autio CLA 2011-10-24 11:23:37 EDT
(In reply to comment #1)
> How did you create a java project with a colon in the name? Eclipse doesn't
> allow it and gives ": is an invalid character in resource name
> 'problem-test:project'" error.

On Mac OS X (I'm running 10.6.8) colon is allowed as a name for at least general Project and Java Project.
Comment 3 Ayushman Jain CLA 2011-10-24 12:09:19 EDT
(In reply to comment #2)
> On Mac OS X (I'm running 10.6.8) colon is allowed as a name for at least
> general Project and Java Project.

Sorry I wasnt aware of this. :)
Reproduced on Mac. Moving to jdt/debug
Comment 4 Dani Megert CLA 2013-07-17 04:30:23 EDT
*** Bug 413078 has been marked as a duplicate of this bug. ***
Comment 5 Michael Rennie CLA 2013-07-17 10:01:59 EDT
I reproduced using Mac 10.8.6 and a 1.6 / 1.7 /1.8 VM. This is a VM limitation / configuration issue because I cannot launch a program from the command line that has a colon in it either. For example:

mrennie-mini:~ mrennie$ /vms/jdk1.8.0/bin/java -classpath /Users/mrennie/Documents/runtime-Eclipse4.3/foo:bar/bin Main
Error: Could not find or load main class Main

is the command line output, which matches what happens in Eclipse. 

This is expected because the colon is a command line delimiter for classpath entries on Mac / *nix, so in effect you wind up with two entries on the classpath: /Users/mrennie/Documents/runtime-Eclipse4.3/foo and bar/bin; neither of which has the Main class in it.

I'm not sure there is anything we can do to fix this, on the commandline I tried the usual escaping tricks, but none worked. I'll dig around a bit more, but we should probably also add some checks to the JavaLaunchDelegate to fail and alert the user to the problem rather than print a cryptic message to the console.
Comment 6 Markus Keller CLA 2013-07-17 10:45:34 EDT
And to top the confusion, the Finder shows a ':' in a file/folder name as a '/'.
(except in the Get Info dialog when rendering a folder path in the "Where:" field).
Comment 7 Michael Rennie CLA 2013-08-13 00:25:47 EDT
*** Bug 287867 has been marked as a duplicate of this bug. ***
Comment 8 Eclipse Genie CLA 2020-04-16 13:39:07 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.