Where can I find eclipse icons? - eclipse

I search for a library, a ".zip"-archiv or another easy way to get all "eclipse-icons". I mean the icons on the top of the tabs (Error, Debug, Search, Task and so on..)
Any idea?

Eclipse actually has a special view that shows all available icons:
Window ▸ Show View ▸ Other... ▸ Plug-in Development ▸ Plug-in Image Browser

Do you want to find the plugin they are in, or download similar ones? Try http://eclipse-icons.i24.cc/

I found it was much easier to just write a little program to extract the images. The code below pulls out all *.png from the JAR files in the Eclipse plugins directory.
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ExtractEclipseIcons {
public static void main(String[] args) {
String dir="C:\\eclipse\\e47dtp\\eclipse\\plugins";
for (File file : new File(dir).listFiles()) {
if(file.getName().endsWith(".jar")) {
unpackImagesFromJAR(file);
}
}
}
private static void unpackImagesFromJAR(File file) {
try (ZipFile zip = new ZipFile(file)){
for (ZipEntry ze : Collections.list(zip.entries())) {
String name = ze.getName();
if(name.endsWith(".png")) {
try(InputStream in = zip.getInputStream(ze)){
String outname = file.getName()+"/"+name;
File outfile = new File("data/"+outname.replace('/', '_').replace('\\', '_'));
stream2File(in,outfile);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void stream2File(InputStream is, File file) throws IOException {
byte[] buffer = new byte[8 * 1024];
try {
OutputStream output = new FileOutputStream(file);
try {
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
} finally {
output.close();
}
} finally {
is.close();
}
}
}

Try this tool: http://www.angusj.com/resourcehacker/
It allows you to extract/cange nearly any icon/pic inside an exe file.

Related

Why am I receiving an error, saying that the Plugins.yml file doesn't exist when it does?

Main.java
package me.FactoryMC.FactoryBlocks;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
#Override
public void onEnable() {
this.saveDefaultConfig();
this.getServer().getPluginManager().registerEvents(this, this);
}
#Override
public void onDisable() {
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("fblock")) {
if (!sender.hasPermission("factoryblocks.reload")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&cYou require &6Dev &cor higher to use this command."));
return true;
}
if (args.length == 0) {
// - /fblock
sender.sendMessage(ChatColor.RED + "Use the correct format: /fblock reload");
return true;
}
if (args.length > 0) {
// - /fblock reload
if (args[0].equalsIgnoreCase("reload")) {
for (String msg : this.getConfig().getStringList("language.reload")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
}
this.reloadConfig();
}
}
}
return false;
}
#EventHandler
public void onBlockBreak(BlockBreakEvent event) {
this.getConfig().getConfigurationSection("blocks").getKeys(false).forEach(key -> {
if (key.equalsIgnoreCase(event.getBlock().getType().toString())) {
ItemStack[] items = new ItemStack[this.getConfig().getStringList("blocks." + key).size()];
ItemStack item = null;
int position = 0;
Random r = new Random();
for (String i : this.getConfig().getStringList("blocks." + key)) {
try {
item = new ItemStack(Material.matchMaterial(i), r.nextInt(16));
} catch (Exception e) {
item = new ItemStack(Material.matchMaterial(key));
}
items[position] = item;
position++;
}
int num = r.nextInt(items.length);
event.setDropItems(false);
World world = event.getPlayer().getWorld();
world.dropItemNaturally(event.getBlock().getLocation(), items[num]);
}
});
}
}
plugin.yml
main: me.FactoryMC.FactoryBlocks.Main
name: FactoryBlocks
author: FactoryMC
version: 1.0
commands:
FactoryBlocks:
Error Message:
Could not load 'plugins\FactoryBlocks.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:160) ~[server.jar:git-Spigot-37d799b-3eb7236]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[server.jar:git-Spigot-37d799b-3eb7236]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:383) ~[server.jar:git-Spigot-37d799b-3eb7236]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:185) ~[server.jar:git-Spigot-37d799b-3eb7236]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:808) ~[server.jar:git-Spigot-37d799b-3eb7236]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[server.jar:git-Spigot-37d799b-3eb7236]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_271]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
Screenshot (File Formatting)
https://gyazo.com/0167c82d654139c4df62d78f10829879
If you haven't already noticed, I'm new to coding Minecraft Plugins - and I saw this as a good plugin to start off with. I've been trying to figure out how this is an error, but I couldn't figure it out.
Undoubtedly someone will be able to pick it up just by first glance, thanks.
Your plugin.yml should not be inside your package! The plugin.yml (and config.yml) needs to be directly in the Java Project.

Can't seems to load dlls in java Web Start

I'm having a huge problem with my java webstart application, I have tries a lot of solutions, but none seems to work correctly in th end.
I need to write a webstart applet to load basic hardware info about the client computer to check if my client can connect on our systems and use the software four our courses. I use Sigar to load the CPU and Memory information and then use JNI to load a custom c++ script that check the graphic card name (This one works perfectly).
I've put all my dlls in src/resources folder to load them in the jar, I also use what we call here "engines" which are classed that do specified operations (In our case, Jni Engine, Config Engine and Data Engine (Code below)), I'm new to webstart so I'm not sure if this concept works well with library loading.
I've tries to add the dlls in a jar as a library in Netbeans, I've tried to add the dlls in the jnlp, but each run recreates it and I can't add them with project properties, finnaly, I've built my Data Engine in a way that should load the dlls in the java temp directory in case they are not there, but Sigar still don't want to work. I've also put my dll in the java.library.path correctly cofigured (As it works in local).
It work when I run my main class locally (With right click-run), but when I click the run button to load the webstart, it crashes with this error message (it happens in ConfigEngine as it extends SigarBase) :
JNLPClassLoader: Finding library sigar-amd64-winnt.dll.dll
no sigar-amd64-winnt.dll in java.library.path
org.hyperic.sigar.SigarException: no sigar-amd64-winnt.dll in java.library.path
Here's the code :
JNi Engine (Loads the c++ code for the graphic card)
package Engine;
public class JniEngine
{
static private final String nomLibJni = "JniEngine";
static private final String nomLibJni64 = "JniEngine_x64";
static
{
if (System.getProperty("os.arch").contains("86"))
{
System.loadLibrary(nomLibJni);
}
else
{
System.loadLibrary(nomLibJni64);
}
}
public native String getInfoGPU() throws Error;
}
ConfigEngine
package Engine;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.cmd.SigarCommandBase;
public class ConfigEngine extends SigarCommandBase
{
private final String nomOsAcceptes = "Windows";
static
{
DataEngine data;
}
public ConfigEngine()
{
super();
}
#Override
public void output(String[] args) throws SigarException
{
}
public HashMap<String, String> getMap() throws SigarException, SocketException
{
HashMap<String, String> hmConfig = new HashMap<>();
loadInfoCpu(hmConfig);
loadInfoRam(hmConfig);
loadInfoOs(hmConfig);
loadInfoNet(hmConfig);
loadInfoGpu(hmConfig);
return hmConfig;
}
private void loadInfoCpu(HashMap<String,String> Hashmap) throws SigarException
{
org.hyperic.sigar.CpuInfo[] configCpu = this.sigar.getCpuInfoList();
org.hyperic.sigar.CpuInfo infoCpu = configCpu[0];
long cacheSize = infoCpu.getCacheSize();
Hashmap.put("Builder", infoCpu.getVendor());
Hashmap.put("Model" , infoCpu.getModel());
Hashmap.put("Mhz", String.valueOf(infoCpu.getMhz()));
Hashmap.put("Cpus nbr", String.valueOf(infoCpu.getTotalCores()));
if ((infoCpu.getTotalCores() != infoCpu.getTotalSockets()) ||
(infoCpu.getCoresPerSocket() > infoCpu.getTotalCores()))
{
Hashmap.put("Cpus", String.valueOf(infoCpu.getTotalSockets()));
Hashmap.put("Core", String.valueOf(infoCpu.getCoresPerSocket()));
}
if (cacheSize != Sigar.FIELD_NOTIMPL) {
Hashmap.put("Cache", String.valueOf(cacheSize));
}
}
private void loadInfoRam(HashMap<String,String> Hashmap) throws SigarException
{
org.hyperic.sigar.Mem mem = this.sigar.getMem();
Hashmap.put("RAM" , String.valueOf(mem.getRam()));
Hashmap.put("Memoery", String.valueOf(mem.getTotal()));
Hashmap.put("Free", String.valueOf(mem.getUsed()));
}
private void loadInfoOs(HashMap<String,String> Hashmap) throws SigarException
{
Hashmap.put("OS", System.getProperty("os.name"));
Hashmap.put("Version", System.getProperty("os.version"));
Hashmap.put("Arch", System.getProperty("os.arch"));
}
private void loadInfoNet(HashMap<String,String> Hashmap) throws SocketException
{
List<NetworkInterface> interfaces = Collections.
list(NetworkInterface.getNetworkInterfaces());
int i = 1;
for (NetworkInterface net : interfaces)
{
if (!net.isVirtual() && net.isUp())
{
Hashmap.put("Port Name " + String.valueOf(i), net.getDisplayName());
}
i++;
}
}
private void loadInfoGpu(HashMap<String,String> Hashmap) throws SocketException
{
if (System.getProperty("os.name").contains(nomOsAcceptes))
{
JniEngine Jni = new JniEngine();
Hashmap.put("VGA", Jni.getInfoGPU());
}
}
}
Finally my Data Engine which tries to load all the dlls and change the library path (Most of it is temporary as it is patches on patches)
package Engine;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
public class DataEngine
{
static private final String nomLibSigar = "sigar-x86-winnt";
static private final String nomLibSigar64 = "sigar-amd64-winnt";
static private final String nomLibJni = "JniEngine";
static private final String nomLibJni64 = "JniEngine_x64";
static private final String NomJar86 = "lib_config_x86";
static private final String nomJar64 = "lib_config_x64";
static private final String path = "Resources\\";
static
{
try
{
if (System.getProperty("os.arch").contains("86"))
{
System.loadLibrary(nomLibJni);
System.loadLibrary(nomLibSigar);
}
else
{
System.loadLibrary(nomLibJni64);
System.loadLibrary(nomLibSigar64);
}
}
catch (UnsatisfiedLinkError ex)
{
loadJniFromJar();
loadSigarFromJar();
}
}
public static void loadSigarFromJar()
{
try
{
File dll;
InputStream is;
if (System.getProperty("os.arch").contains("86"))
{
is = DataEngine.class.getResourceAsStream(
path + nomLibSigar + ".dll");
dll = File.createTempFile(path + nomLibSigar, ".dll");
}
else
{
is = DataEngine.class.getResourceAsStream(
path + nomLibSigar64 + ".dll");
dll = File.createTempFile(path + nomLibSigar64, ".dll");
}
FileOutputStream fos = new FileOutputStream(dll);
byte[] array = new byte[1024];
for (int i = is.read(array);
i != -1;
i = is.read(array))
{
fos.write(array, 0, i);
}
fos.close();
is.close();
System.load(dll.getAbsolutePath());
System.setProperty("java.library.path", dll.getAbsolutePath());
}
catch (Throwable e)
{
}
}
public static void loadJniFromJar()
{
try
{
File dll;
InputStream is;
if (System.getProperty("os.arch").contains("86"))
{
is = DataEngine.class.getResourceAsStream(
path + nomLibJni + ".dll");
dll = File.createTempFile(path + nomLibJni, ".dll");
}
else
{
is = DataEngine.class.getResourceAsStream(
path + nomLibJni64 + ".dll");
dll = File.createTempFile(path + nomLibJni64, ".dll");
}
FileOutputStream fos = new FileOutputStream(dll);
byte[] array = new byte[1024];
for (int i = is.read(array);
i != -1;
i = is.read(array))
{
fos.write(array, 0, i);
}
fos.close();
is.close();
System.load(dll.getAbsolutePath());
}
catch (Throwable e)
{
}
}
}
I also have some problem with my main class (NetBeans don't want my JAppletForm to be the main class of my project, but I'll probably recreate the project anyway since the hundreds of patches I tries have corrupted the build. My main class simply load the HashMap with GetMap of ConfigEngine and show it in the console if local or in the JAppletForm if it runs with webstart.
Its a pretty big problem so I'll update my question with all the info you'll need if asked.

Is it possible to extract a large file using Truezip in java?

import java.io.IOException;
import utils.myDate;
import utils.myLog;
import de.schlichtherle.truezip.file.TArchiveDetector;
import de.schlichtherle.truezip.file.TFile;
public class Main
{
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Extract(new String("C:/Documents and Settings/mitracomm/My Documents/Downloads/JAR"), new String("D:/Source/Extract Result") , "");
}
private static void Extract(String src, String dst, String incPath)
{
TFile srcFile = new TFile(src + "/" + incPath);
TFile dstFile = new TFile(dst);
try {
TFile.cp_rp(srcFile, dstFile, TArchiveDetector.ALL);
} catch (IOException e) {
myLog.add(myDate.today("yyyyMMdd") + ".log", "error", e.getMessage());
}
}
Will the above code work with a large archive? Also, how can I extract every archive in a directory without having to fill the incPath or specify archives' name? I have tried to do this but I end up with copies of all the archives from origin directory and not extracted files.
The code is principally OK, but I'ld use:
public class Main {
public static void main(String[] args) {
Extract(new String("C:/Documents and Settings/mitracomm/My Documents/Downloads/JAR"), new String("D:/Source/Extract Result") , "");
}
private static void Extract(String src, String dst, String incPath) {
TFile srcFile = new TFile(src, incPath);
TFile dstFile = new TFile(dst);
try {
TFile.cp_rp(srcFile, dstFile, TArchiveDetector.NULL);
} catch (IOException e) {
// I don't like logging for this purpose, but if you must...
myLog.add(myDate.today("yyyyMMdd") + ".log", "error", e.getMessage());
}
}
}
I'm not sure if you really want three arguments for the Extract method, though.
And finally, yes TrueZIP handles ZIP files beyond 4GB size correctly.

filenotfound issues in eclipse on Mac OSX

Hi
I have a java class which is working fine in windows but not in Mac OSX snow leopard. I am using Eclipse on both operating systems. On Mac OSX its throwing file not found exception.
Basically I am trying to read a file using BufferedReader and FileReader and I put my file in \resources\
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadFileContents {
/**
* #param args
*/
public static void main(String[] args) {
BufferedReader br = null;
String line = "";
try {
br = new BufferedReader(new FileReader("resources\\abc"));
while((line = br.readLine())!= null)
{
System.out.println("Read ::: "+line+" From File.");
}
} catch (FileNotFoundException fne) {
fne.printStackTrace();
}catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
On Mac it is giving
java.io.FileNotFoundException: resources\abc (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at java.io.FileReader.<init>(FileReader.java:41)
at ReadFileContents.main(ReadFileContents.java:18)
Do I need any special configuration in my eclipse to get this working...
Mac uses forward slashes: "resources/abc". (This will actually work on Windows as well. Only the command line interpreter requires backslashes.)

(Eclipse RCP) How to redirect the output to Console View?

I have two viewers, one has a Text for user's input and the other viewer is the Eclipse's built_in Console View. And I will run an java program according user's input, and want to display the log information in the ConsoleView. Does anybody know How can I redirect the output to Console View ?
Thanks
SO questions How to write a hyperlink to an eclipse console from a plugin and writing to the eclipse console give example of redirection to the Console.
The blog post Displaying the console in your RCP application
The ideas remain to create an OuputStream and open a New Console, or associating the MessageStream of a console to stdout adn stderr (like my previous answer)
Redirect output on RCP console:
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.annotation.PostConstruct;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
public class ConsoleView {
private Text text;
#PostConstruct
public void createPartControl(Composite parent) {
text = new Text(parent,
SWT.READ_ONLY | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
OutputStream out = new OutputStream() {
StringBuffer buffer = new StringBuffer();
#Override
public void write(final int b) throws IOException {
if (text.isDisposed())
return;
buffer.append((char) b);
}
#Override
public void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len);
flush();
}
#Override
public void flush() throws IOException {
final String newText = buffer.toString();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
text.append(newText);
}
});
buffer = new StringBuffer();
}
};
System.setOut(new PrintStream(out));
final PrintStream oldOut = System.out;
text.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
System.setOut(oldOut);
}
});
}
#Focus
public void setFocus() {
text.setFocus();
}
}
The screenshot: