I want to change contains of file Meta-inf/Manifest.mf . I try this:
org.openide.filesystems.FileObject projectDirectory = project.getProjectDirectory();
FileObject modulesFileObject = projectDirectory.getFileObject("build/cluster/modules/");
properties.store(propertiesFile.getOutputStream(), null);
but I got this Exeption:
manifest.mf is read-only because it is inside.
Jar file is not read-only. So can you help me, please?
PS: I use NetBeans Platform RCP 7.11 , java 1.7_07
Thank Jirka
The problem is, that the JarSystem is read-only.
Jirka
Related
There is old Eclipse Image Viewer plugin https://github.com/persal/quickimage
that I want to update.
After adding maven/tycho build and building against Kepler.
It works in new Eclipse instance (project -> run as Eclipse application),
but when installing here is an issue #6
org.eclipse.swt.SWTException: i/o error (java.io.FileNotFoundException: file:\D:\Progs\Eclipses\eclipse-standard-luna-R-win32-x86_64\eclipse\plugins\nu.psnet.quickimage.plugin_1.1.0.201503030326.jar!\icons\previous.gif (The filename, directory name, or volume label syntax is incorrect.))
文件名、目录名或卷标语法不正确
Looking at the code there is line
iconsdir = FileLocator.resolve(QuickImagePlugin.getDefault().getBundle().getEntry("/")).getFile() + "icons" + File.separator;
that gets path like that.
The problem is that should work if the bungle jar becomes folder like nu.psnet.quickimage_1.0.3.2
UPDATE: As IDE using Luna 4.4.0
If you can change the source of the plugin you can change
iconsdir = FileLocator.resolve(QuickImagePlugin.getDefault().getBundle().getEntry("/")).getFile() + "icons" + File.separator;
to something like:
URL dir = FileLocator.find(QuickImagePlugin.getDefault().getBundle(),
new Path("icons"), null);
dir = FileLocator.toFileURL(dir);
String iconsdir = dir.getPath() + File.separator;
This should work even when the plugin is packaged in a jar.
This is controlled by a flag in feature.xml where the plugin is included.
<plugin id="..." unpack="true"/>
I know there have already been some questions about relative paths, but I Keep failing to get JavaFX FXML loader to load a resource from a package other than itself.
The loading class is located in the package gui.controllers and the fxml file BarSheet.fxml is located in the package gui.resources.
What should i now put in :
FXMLLoader myLoader = new FXMLLoader(getClass().getResource("src/gui/resources/BarSheet.fxml"));
Thanks in advance
SOLVED: The fault was in the fact that my fxml file contained an error so i didnt know when i entered the right path because it would still not work...
The path should start with / to indicate the path starting from the root followed by packages/filename. So in my case
FXMLLoader myLoader = new FXMLLoader(getClass().getResource("/gui/resources/BarSheet.fxml"));
As a complement when you have a package like com.company.view, and inside you have the .fxml file in order to make this work you have to put the line like this:
FXMLLoader myLoader = new FXMLLoader(getClass().getResource("/com/company/view/file.fxml"));
i have created a jar-file (DicoDB.jar) with Eclipse in the folder called 'program-jar'. Inside a subdirectory 'javahelp' are the following jar-files: jhall.jar, hsviewer.jar, jh.jar and dicoDBHelp.jar (this is my jar-file which contents my help-application).
In the top directory 'program-jar' are also the following jars: jgraph.jar, gnujpdf.jar.
This is my MANIFEST.MF: (The file is manually created)
Manifest-Version: 1.0
Main-Class: gui.DicoDB
Class-Path: jgraph.jar
gnujpdf.jar
javahelp/jhall.jar
javahelp/hsviewer.jar
javahelp/jh.jar
javahelp/dicoDBHelp.jar
At the end of the file is an empty line.
Now I execute the DicoDB.jar in my terminal. Everything works fine until I want to open my help-file (dicoDBHelp.jar).
I get the following exception:
java.lang.NoClassDefFoundError: javax/help/JHelp
The JHelp class is contained by jhall.jar.
Now I don't undertand why the program does not find the class.
So i hope somebody can help me.
Just a thought: try to put all jars in the same line as Class-Path: .... separated by spaces.
How can I create a new build path entry for any *.jar file and add this classpath entry to the build path of an Eclipse project.
I have a plugin that should automatically setup my target project. So this project needs to have some library imports and I want to add this imports automatically using a wizard. The user just selects the location of a certain SDK and then some libraries have to be linked with the target project.
However, I found some references:
Importing libraries in Eclipse programmatically
How to add a folder to java build path as library, having multiple jars or entries in it?
Unfortunately, I failed to implement the second solution as I cannot find the classes IClasspathContainer, JavaCore and IJavaProject.
I'm using Eclipse Helios and JDK. Do I need any additional libraries to make changes to the build path or is there a simpler solution to import a jar library programmatically?
Regards,
Florian
I'm assuming that you are creating a plugin and need your plugin to manage the extra jars added to the classpath.
As you mention, you need to create a custom classpath container. First, create the classpath container extension by exending this extension point:
org.eclipse.jdt.core.classpathContainerInitializer
Then, you create a class that implements org.eclipse.jdt.core.IClasspathContainer and associate it with the extension point you just created.
You mention that you cannot find the org.eclipse.jdt.core.IClasspathContainer interface. You need to make sure that your plugin references the org.eclipse.jdt.core plugin in its MANIFEST.MF.
Here you can find some examples, how to define new classpath entries and classpath containers to java projects. I think it would handy for someone reading this question.
In order to get access to IJavaProject etc, goto your plugin.xml and add org.eclipse.jdt.core to the classpath. Thereafter you can import those packages into your project.
String projectName = "MyProject"; // project to add a library to
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
IJavaProject jProject = JavaCore.create(project);
for(File file : new File("path-to-some-directory-of-libraries-to-add").listFiles()){
if(file.isFile() && file.getName().endsWith(".jar")){
addProjectLibrary(jProject, file);
}
}
private static void addProjectLibrary(IJavaProject jProject, File jarLibrary) throws IOException, URISyntaxException, MalformedURLException, CoreException {
// copy the jar file into the project
InputStream jarLibraryInputStream = new BufferedInputStream(new FileInputStream(jarLibrary));
IFile libFile = jProject.getProject().getFile(jarLibrary.getName());
libFile.create(jarLibraryInputStream, false, null);
// create a classpath entry for the library
IClasspathEntry relativeLibraryEntry = new org.eclipse.jdt.internal.core.ClasspathEntry(
IPackageFragmentRoot.K_BINARY,
IClasspathEntry.CPE_LIBRARY, libFile.getLocation(),
ClasspathEntry.INCLUDE_ALL, // inclusion patterns
ClasspathEntry.EXCLUDE_NONE, // exclusion patterns
null, null, null, // specific output folder
false, // exported
ClasspathEntry.NO_ACCESS_RULES, false, // no access rules to combine
ClasspathEntry.NO_EXTRA_ATTRIBUTES);
// add the new classpath entry to the project's existing entries
IClasspathEntry[] oldEntries = jProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
newEntries[oldEntries.length] = relativeLibraryEntry;
jProject.setRawClasspath(newEntries, null);
}
Note that as Andrew Eisenberg mentioned, you need to include the org.eclipse.jdt.core plugin dependency in your plugin's MANIFEST.MF.
Note that you may also need to programmatically refresh the project too.
I have a jar file named "xyz.jar" that have the file "abc.xml" and I have one more file with same name "abc.xml" not bundled with "xyz.jar" . I would like to have the JBoss to see the "abc.xml" which isnt bundled with "xyz.jar" in the first place before it sees the one that is bundled with "xyz.jar". The reason is , the file "abc.xml" that placed externally can be exposed for modification and that way Jboss can see that modification without restarting the server.
How can I achieve this .. I mean how can I set the classpath for Jboss to see the "abc.xml" that isnt bundled with "xyz.jar" in the first place ?
If you know the location of abc.xml on your filesytem you can just load it using a fully qualified path. For example
final InputStream is = new FileInputStream("/foo/bar/abc.xml");
It isn't about the JBoss classpath. It depends on the way you chose to open your resource abc.xml into your jar xyz.jar
You can set classpath to load resource by editing JBOSS\bin\run.bat
This line allow you to add:
if "x%JBOSS_CLASSPATH%" == "x" (
set "RUN_CLASSPATH=%RUNJAR%;your\link\here;"
) else (set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%;your\link\here;"
)
then execute run.bat
I have added these entries in run.bat 'if "x%JBOSS_CLASSPATH%" == "x" (
set "RUN_CLASSPATH=%RUNJAR%;JBOSS_CLASSPATH.configuration;"
) else (set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%;JBOSS_CLASSPATH.configuration;"
)
Log in got the below ERROR
FOUNDATION_CONFIG_MGR_INIT: com.exception.SystemException: Cannot find the config.xml file in the classpath
Application: Foundation ...