Salut,
Je cherche a récupérer les resources inclusent dans un projet (workspace) et j aimerais accéder a toutes (le classpath du projet)
merci de vos lumières
Salut,
Je cherche a récupérer les resources inclusent dans un projet (workspace) et j aimerais accéder a toutes (le classpath du projet)
merci de vos lumières
Pour l instant j ai écris le code suivant qui me permet de loadé un projet et de récupérer les classpath entry
J aimerais lire le contenu d un jar pour y trouvé un fichier particulier et le charget dans un ResourceSet EMF.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 /** * Gets the current active project. * * @return IProject * The active project */ private IProject getCurrentProject() { IWorkbench iworkbench = PlatformUI.getWorkbench(); if (iworkbench == null) { return null; } IWorkbenchWindow iworkbenchwindow = iworkbench.getActiveWorkbenchWindow(); if (iworkbenchwindow == null) { return null; } IWorkbenchPage iworkbenchpage = iworkbenchwindow.getActivePage(); if (iworkbenchpage == null) { return null; } IEditorPart ieditorpart = iworkbenchpage.getActiveEditor(); return extractProject(ieditorpart); } /** * Extract the project from the editor part. * * @param editor * The active editor * @return IProject * The active project */ private IProject extractProject(IEditorPart editor) { IEditorInput input = editor.getEditorInput(); if (!(input instanceof IFileEditorInput)) return null; return ((IFileEditorInput)input).getFile().getProject(); } /** * Load resource from jar file */ private void loadResource() { IProject project = getCurrentProject(); IJavaProject javaProject = JavaCore.create(project); try{ IClasspathEntry [] classPathEntries =javaProject.getRawClasspath(); for (int i = 0; i < classPathEntries.length;i++) { IClasspathEntry entry = classPathEntries[i]; if (entry.getContentKind() == IPackageFragmentRoot.K_BINARY) { readJarEntries(entry); } System.out.println(entry.getPath().toString()); } }catch (JavaModelException ex) { Logger.error(""); } } /** * Read the specified jar file to search and load the selected file into * the ResourceSet. * * @param entry * The classpath entry */ private void readJarEntries(IClasspathEntry entry) { }
Je viens de tomber sur ta réponse.
Le truc, c'est que ça te sort : "org.eclipse.jdt.launching.JRE_CONTAINER"
Quelqu'un sait comment on fait pour avoir le classpath de "runtime" ? (c'est a dire, le VRAI classpath de compilation java, celui qu'il faut pour "java -cp ********")
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager