Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Can I use JDT as a standalone tool without eclipse env?
Can I use JDT as a standalone tool without eclipse env? [message #657225] Wed, 02 March 2011 03:05 Go to next message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
Hi all:

I am developing a program analysis tool based on JDT core (primarily using the AST parser).

I developed the tool in the eclipse environment, and it works well (running inside an eclipse Java project, not a plugin project).


However, when I plan to export all class into a single jar and release the tool (in other words, executing the program out of eclipse), I found there is an unexpected exception been thrown (as follows). This exception has never been seen before when running my code INSIDE eclipse:

...
Warning: NLS missing message: plugin_notPluginClass in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_unableToResolve in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_pluginDisabled in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_instantiateClassError in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_loadClassError in: org.eclipse.core.internal.runtime.messages
Exception in thread "main" java.lang.ExceptionInInitializerError: Missing message: parser_missingFile in: org.eclipse.jdt.internal.compiler.messages
at org.eclipse.jdt.internal.compiler.parser.Parser.<clinit>(Parser.java:121)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.parse(Compi lationUnitResolver.java:492)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTPars er.java:1194)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java: 801)



Here are all the dependent jars (all from eclipse-3.6.1/plugins dir):

org.eclipse.core.commands_3.6.jar
org.eclipse.core.contenttype_3.4.1.jar
org.eclipse.core.jobs_3.5.1.jar
org.eclipse.core.resources_3.6.0.jar
org.eclipse.core.runtime_3.6.0.v20100505.jar
org.eclipse.equinox.common_3.6.0.jar
org.eclipse.equinox.preferences_3.3.0.jar
org.eclipse.jdt.core_3.6.1.jar
org.eclipse.osgi_3.6.1.jar
org.eclipse.text_3.5.0.jar


So, I guess there maybe some implicitly dependent inside an eclipse project. I step into the trace, and find the code in
org.eclipse.jdt.internal.compiler.parser.Parser#readTable(fi leName) need to load some files like "parse1.rsc" , but I have not found such files in my disk.

I am a bit confused on that. Could any one kindly give me some hints in solving this problem? to release a standalone tool using JDT.

Any comments are highly appreciated.

thanks

-Sai

[Updated on: Wed, 02 March 2011 03:55]

Report message to a moderator

Re: Can I use JDT as a standalone tool without eclipse env? [message #657228 is a reply to message #657225] Wed, 02 March 2011 03:24 Go to previous messageGo to next message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
or do i need to include all dependent jars, when running outside of eclipse?

(since I saw:

plugin_instantiateClassError in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_loadClassError in: org.eclipse.core.internal.runtime.messages

)
Re: Can I use JDT as a standalone tool without eclipse env? [message #657235 is a reply to message #657228] Wed, 02 March 2011 04:39 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Did you rebuild or repackage the JDT/Core jar? Looks like you were missing some non-class files.

You could make your application an Eclipse headless application or include all the dependent jar files in the class path for your application.

You might have to use ASTParser.setSource() and ASTParser.setEnvironment() to be able to parse non Eclipse Java projects.
Re: Can I use JDT as a standalone tool without eclipse env? [message #657243 is a reply to message #657235] Wed, 02 March 2011 06:20 Go to previous messageGo to next message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
Hi Satyam:

Thanks for your reply.

I did not rebuild or repackage the JDT/Core jar. How could I do that? (I am not quite understand repackage here) I am really confused about where are those non-class files? and how did JDT load it.

I try to include all dependent jar files in the classpath, but the same exception is thrown. So, I guess there may be some jars (or files) an eclipse project automatically loads ..

Could you please kindly give me some examples or point me to some resources on the above points? as well as " ASTParser.setSource() and ASTParser.setEnvironment() to be able to parse non Eclipse Java projects."?

Many thanks. your help is highly appreciated.

-Sai
Re: Can I use JDT as a standalone tool without eclipse env? [message #657448 is a reply to message #657235] Wed, 02 March 2011 19:42 Go to previous messageGo to next message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
Hi.

I tried it again, and found it still has the same problem. here is my code:

public static CompilationUnit readASTRoot(String fileName) throws IOException {
File f = new File(fileName);
Checker.checkTrue(f.exists() && f.isFile(), "The file is either not exisited or not a file: " + fileName);

int lastPathSep = fileName.lastIndexOf(Globals.pathSep);
String fileDir = ".";
if(lastPathSep != -1) {
fileDir = fileName.substring(0, lastPathSep);
}
File parent = new File(fileDir);
//create the parser
ASTParser parser = ASTParser.newParser(AST.JLS3);

//Globals.getClasspath()
parser.setSource(Files.getFileContents(fileName).toCharArray ());
parser.setEnvironment(SketchUtil.getClassPathEntries(), new String[]{parent.getAbsolutePath()}, null, true);
parser.setResolveBindings(true);
parser.setKind(ASTParser.K_COMPILATION_UNIT);

return (CompilationUnit)parser.createAST(null);
}

Still throw the same exception ;(

Is it possible that i should never use the parser.createAST(null) method outside eclipse?
Re: Can I use JDT as a standalone tool without eclipse env? [message #657519 is a reply to message #657448] Thu, 03 March 2011 07:18 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
I have just tried putting all the jars in the class path of the java command line and that seems to work for me.

Files like Parser1.rsc files should be in the org.eclipse.jdt.core_3.6.1*.jar. As I understand you were just picking up this jar file directly from the plugins folder.
Re: Can I use JDT as a standalone tool without eclipse env? [message #657979 is a reply to message #657519] Fri, 04 March 2011 19:06 Go to previous messageGo to next message
Sai Missing name is currently offline Sai Missing nameFriend
Messages: 25
Registered: March 2011
Junior Member
thanks so much, Satyam.

I checked the jdt.core_3.6.1*.jar, and found it has been corrupted.

Everything works well after replacing a new one from plugin dir.

However, there are still many annonying messages like:


Warning: NLS missing message: plugin_deactivatedLoad in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_shutdownProblems in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_startupProblems in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: preferences_saveProblems in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_badPrereqOnFrag in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_duplicateFragment in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_duplicateLib in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_internalStack in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unknownElement in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unknownTopElement in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unknownAttribute in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_error in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_errorProcessing in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_errorNameLineColumn in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_validExport in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_validMatch in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unknownLibraryType in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_nullFragmentIdentifier in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_nullPluginIdentifier in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_duplicatePlugin in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unknownEntry in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_missingPluginId in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_missingPluginName in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_missingFPName in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_missingFPVersion in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_missingPluginVersion in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_fragmentMissingAttr in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_pluginMissingAttr in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_pluginMissingIdName in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_fragmentMissingIdName in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_missingFragmentPd in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_extPointDisabled in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_extPointUnknown in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unsatisfiedOptPrereq in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_unsatisfiedPrereq in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_prereqDisabled in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_prereqLoop in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: parse_prereqOptLoop in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_notPluginClass in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_unableToResolve in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_pluginDisabled in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_instantiateClassError in: org.eclipse.core.internal.runtime.messages
Warning: NLS missing message: plugin_loadClassError in: org.eclipse.core.internal.runtime.messages



Do you have idea in how to remove such messages? Do I need to include another jar? or some non-class files?

thanks very much, really appreciate your help.
Re: Can I use JDT as a standalone tool without eclipse env? [message #658140 is a reply to message #657979] Mon, 07 March 2011 04:44 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
It could be similar problem with other plugins. Here I guess the problem is with org.eclipse.core.runtime.
Previous Topic:How to Differentiate The Type of Change (i.e., normal, or undo) using IUndoManagerListener
Next Topic:Workspace Ignores Preferences
Goto Forum:
  


Current Time: Tue Apr 16 23:17:29 GMT 2024

Powered by FUDForum. Page generated in 0.95461 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top