- This topic has 5 replies, 3 voices, and was last updated 15 years, 10 months ago by Loyal Water.
-
AuthorPosts
-
mengmvnMemberthis happens on 5.5.1, 6.5.1 and 7.0 version.
If we change the “Java Build Path” –> “Default output folder” location from projectName/target/classes to projectName/classes (remove the target). After the compiling, click a java file and choose run as java application, it give the error message — java.lang.NoClassDefFoundError… Exception in thread “main”. Seems the “User Entries” of the projectname under the Classpath of Java Application can not find its compiled classes path
Developers need to open the Java Application config and change its Classpath by –> Advanced–> add folder to add it to the generated classes location. For example, the default is laww, now in the User Entries, it looks like “classes \laww\” , we got to do this for each file we want to run as Java application. Is there any globle setting for the classpath, or how to fix this problem ?
In our company, the projectName/classes is the output location we use, and not going to change it.
Thanks in advance.
Meng
Riyad KallaMemberMeng,
projectName/target/classes is normally the default output for Maven-based builds — if you are using Maven to build your project, unless you change that default in your pom.xml, the reason your running app is failing is because MyEclipse isn’t building your project to the new output path (which is fine) but Maven is building it to the *old* output path and the “Run as Application” is an Eclipse function that doesn’t heed any Maven design guidelines, so it will check the (empty) output folder and barf.
What you are trying to do is perfectly fine and supported, so the fact that you are running into trouble makes me think that something else is going on. Out of curiosity, when you switch to the navigator view and look at the artifacts in your project, are the classes getting built out to the new projectName/classes folder correctly or are they still building to projectName/target/classes?
mengmvnMemberActually we use Maven4MyEclipse to manage the dependency and run some maven goals, such as wsdl to java, idl to java.
But when we really build the project, we use MyEclipse to do the compiling (Project–>Build projects)When we change the Default output folder to projectName/classes, the compiled java classes file are located on projectName/classes.
But seems the item(projectName)in the User Entries under Classpath Tab in Java Application is referring to something else (I guess it points to
projectName/target/classes).As I mentioned before, we got to click the Advanced Options, click the Add Folders, and points to projectName/classes, then it working. but we got to do each class if we want to run it by Java Application.
How to make the projectName under User Entries in the Classpath of Java Application cofig to points to the Default output folder ? When the value of the
Default output folder has been changed, this value will change as well ?Please help, I do no want this will hold us switch from Jbuilder to MyEclipse.
Thanks
Meng
Riyad KallaMemberMeng,
The item you are referring to on the run configuration’s Classpath should just be a “Default Classpath” entry, which is basically just the output dir of your project, which you set on the Java Build Path preference page as you said you did. I’ve attached some screenshot examples from my project.
If this is similar to what you see and it’s *still* not working, can you grab some screenshots showing me what you are seeing and possibly walking me through how to setup a problomatic project so I can reproduce this?
Attachments:
You must be logged in to view attached files.
mengmvnMemberIn my 5.5.1 and 7.0 version MyEclipse, in the classPath it looks like
— User Entries
laww
Maven Dependenciesbut in your screen shot, it is
— User Entries
–projectName (default classpath)
projectName
dependent jarsNot sure how the –projectName (default classpath) is missing from my MyEclipse or how you config it so it will defalut to this setting.
Note-
1. laww is our projectName = your M4MContactManagerExample
2. I did not change anything on run as Java Application config, it is automatically create the javaFileName under Java Application
In your screen shot, the javaFileName is Main
3. the Defalut output folder is laww/classes and the generated classes are dump here.I still not figure out how to attached screen shot here, if not so complicated, you may show me how.
If you like, you can send me a email to shiqiang_meng@uhc.com, I will reply with screen shot.
I really need to give this issue resolved for the moving to maven2 enabled.Thanks a lot
Meng
United HealthGroup
Loyal WaterMemberMeng,
You can hit the PM button at the bottom of my post and send me the screen shot. This is a button on the bottom left hand corner of my post between the profile and email button.Also, can you list the exact steps to help me create a similar project at my end.
-
AuthorPosts