Experts in java -behold my question
my problem is:
i have a jar.there are two packages in the jar
in the fisrt package i have some class call registar.
the second jar i have many classes .
i want to use a function in registar which loop all the files in the second jar ,and have them in some array.
all this when i am running the jar
yoav
all i managed to do was to load a class if i know the name and can cast it.but when i dont know the name,and it found on different jar,that on so trivial
i will be more spesific.jar a has two classes a.class and b.class
its in jar hello.jar.
second jar ,read the entries in the hello jar,and then using something like URLClassLoader methods(which i didnt figured which and how),will insert the name of the class as key in map,and the className.class as a value in th map
the result will be
string |a.class(not string presentation but the object it self)
you were right telling me to use the URLClassLoader/CLassLoader but how?
if you can be more spesific it will be great
thanks,yoav
Similar Messages
-
Language experts: Port Java Code to AS3?
Hello out there,
I have been asked whether it would be feasable to translate Java code to AS3. This is a bit difficult since I am not really an expert in Java and only a beginner wrt AS3. Looking at some code samples it seems doable (at least in principle), but of course there might be hidden gotchas lurking. Hence:
- Are there Java features which do not have an equivalent in AS3?
- Does AS3 have prerequisites which do not exist in Java?
- Other aspects to consider?
Any comment or advice will be greatly appreciated.
Best regards
H.Thanks to you all.
In the meantime I read "Actionscript for Java developers"
http://www.javaworld.com/javaworld/jw-02-2009/jw-02-actionscript1.html
and it seems like the two languages are not too far apart.
Of course there are differences, but we only need to consider those features which Java has and AS has not (like method overloading) and modify our Java sources to not use these. Since the goal is not to have a universal tool which translates _any_ kind of Java source to AS but only our specific code base I think it will be worth a small effort to test how far we get with a machine translation.
Yes, libraries may well be an issue - but again, I would have to see which (library) functions are actually used and how to replace them.
Thanks again and best regards
H. -
Simple Java Network Programming Question
import java.io.*;
import java.net.*;
public class ConsumerClient
private static InetAddress host;
private static final int PORT = 1234;
private static Socket link;
private static Resource item;
private static BufferedReader in;
private static PrintWriter out;
private static BufferedReader keyboard;
public static void main(String[] args) throws IOException
try
host = InetAddress.getLocalHost();
link = new Socket(host, PORT);
in = new BufferedReader(new InputStreamReader(link.getInputStream()));
out = new PrintWriter(link.getOutputStream(),true);
keyboard = new BufferedReader(new InputStreamReader(System.in));
String message, response;
do
System.out.print("Enter 1 for resource or 0 to quit: ");
message = keyboard.readLine();
if(message.equals("1")**
item.takeOne();**
//Send message to server on
//the socket's output stream...
out.println(message);
//Accept response from server on
//the socket's input stream...
response = in.readLine();
//Display server's response to user...
System.out.println(response);
}while (!message.equals("0"));
catch(UnknownHostException uhEx)
System.out.println("\nHost ID not found!\n");
catch(IOException ioEx)
ioEx.printStackTrace();
finally
try
if (link!=null)
System.out.println("Closing down connection...");
link.close();
catch(IOException ioEx)
ioEx.printStackTrace();
}georgemc wrote:
BlueNo yel-- Auuuuuuuugh!
But the real question is: What is the air-speed velocity of an unladen swallow? -
WD Java iView Creation Question/Issue - CE 7.1 EHP 1 Trial
Hi all,
Im posting this question here seeing as that the issue has arrised on an installation of the AS JAVA and EP shipped with CE 7.1 EHP1 Trial.
When attempting to create an iView for a deployed custom WD Java app on the trial Portal I am taken straight to the iView template selection without being given the options for iView creation( ie. create from template, portal component or WD Java app). Is this by design ( WD Java iView creation has changed from previous Portal versions or is limited in Trial installation), is this an issue with the components shipped with the Trial or an issue on my installation only?
Currently my only solution for deploying WD java content is to copy the actual application and paste it as Portal content which then creates a WD Proxy page with a single WD Proxy iView (that of the copy pasted WD app). This is fine for single app scenarios but becomes an issue with multiple apps on one page and drag and relate scenarios.
Kind regards,
Willem.Hi Williem
Please check the SAP CE 7.1 EHP1 documentation for more information.
[CE 7.1 documentation|http://help.sap.com/saphelp_nwce711/helpdata/en/44/d958673ef05f4de10000000a11466f/frameset.htm]
[CE 7.1 iViews |http://help.sap.com/saphelp_nwce711/helpdata/en/f5/eb51590e6a11d7b84900047582c9f7/frameset.htm]
Hope this will helps you.
Thanks
Arun Jaiswal -
Help AVL Tree in JAVA code (remove) question-answer
Hi,
everyone. I have question.
I want codes in Java for AVL Tree.
I but must have remove methods or choose elements.
It`s main for me.
If you know, please write in code JAVA or contact e-mail.
or link to page or if you have self code.
thanks,
regards
[email protected]I have a better idea.
Why don't you try to do it yourself, and when you get stuck, post your code and details of what difficulty you're having.
When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read. -
Java Programming Language questions...???
Hi everybody....
Can I post here my questions about Java Programming Language....or only to to the relevant Sun's forum....http://forum.java.sun.com/index.jspa???
My greetings,
SimonSimon,
sure, the worst thing that could happen is that people point you to the SUN forum. Usually this forum answers general Java questions.
Frank -
Java reflection (interesting question)
hi folks,
class A {
void foo() {
Class B overrides method foo() in A
class B extends A {
void foo() {
Now i create a object of class B and assign to A
A aref = new B();
aref.foo() will call method foo()of class B. //polymorphism
Using reflection, is it possible to call method foo() of class A using the handle aref.
thanks
venkathi bondvenky,
What abt the answer for my original question. How to
access the base class methods using the handle for
child class object using reflection ?as far as i know, this isn't possible - your next question is probably going to be "why". It certainly seems slightly surprising that you can't do this, but you can access private methods. Unless you consider the latter a weaker way of breaking encapsulation (!?).
what was the sun's purpose behind allowing access to
the private methods of an object using Java
Reflection? good question.. its very useful but on the other hand i can't think of a time i've used it that couldn't be classed as a hack.
Is it not a security threat to java security model?it doesn't break anything - ie its not a security loophole. It links in with your question above though - would it have been possible/useful to not allow it period?
sorry for the vague answers :(
asjf -
Java/OO Design question. Please help!
Brian,
I'd say your better off trying the
weblogic.developer.interest.ejb newsgroup
or alternatively try the discussion forums in
www.theserverside.com
or
http://forum.java.sun.com/
For what its worth I'd return an empty array rather than an exception as I associate
exceptions with real errors whereas a search that happens to return nothing is a
valid result.
Cheers,
mairt
"Brian Snyder" <[email protected]> wrote:
>
I'm certain this is not the best forum for my question, but I didn't any
other
that seemed obvious.
I have a design issue/ OO question. Our system has the very common requirement
of searching. We have build a session EJB which actually performs the search
and returns a collection of Value Objects back to the client. My question
is
this: If the search EJB finds no matching records, what is the correct
strategy
for dealing with it?
1) Throw an application exception, such as "NoDataFound", which the client
can
catch and handle appropriately
2) Simply return a null collection. In which case, the client will have
to check
for null, and redirect program appropriately.
3) Simple return type, such as boolean, for the method -- indicating success
or
failure (meaning no records found).
4) Something entirely different. If so, what?
Your thoughts on this subject would be greatly appreciated!
Thanks!
Brian -
AutoVue for Agile PQM - Java Runtime Environment Question
Greetings,
An end user is attempting to view/open attachments within Agile Product Quality Management (PQM); we use Agile PQM 9.3.1.
When clicking on an attachment file, a pop-up screen opens with a javascript alert, prompting the user with, "Please Install Java Runtime Environment." After clicking "OK", user is redirected to java download website. User downloads and installs the update.
After rebooting the machine, we attempt to access the attachment file again within PQM and receive the same error message, "Please Install Java..."
After installing the first java update, the user is now on the following java version:
Java Plug-in 10.55.2.14
Using JRE version 1.7.0_55-b14 Java HotSpot(TM) Client VM
Do we need to install the second update to be able to view attachments within Agile PQM via AutoVue?
I can't test the java updates myself because there are some legacy Oracle apps that I won't be able to support if I update my java.
Thanks in advance,
WilliamYou might want to post the question to the Agile forum
The popup you see seems to be tied to Agile code itself and not AutoVue
AutoVue will work on Java 7u55
But you are running Agile, so you will need to make sure the rest of the apps are confirmed with 7u55
You also need to review Java update guidelines, by default you will be always prompted to install the latest java update -
I have a java Command line running program. Which allow input/edit data of clients and store them into a Flat file. The problem is that i have to make a GUI, ( a thin web based client ) and using only HTML and Javascript.
The next step is the db should be frontended by servlet or JSP that interact with thin client to perform the database retrievals.
Now my concept Questions:
1. Is it possible to communicate to a Java Program using HTML and Javascript? If so, any exampler, pointers?
2. I was thinking of using HTML and Javascript to directly modify the Database. ( Since it is a flat file therefore nothing more than a txt file ) But isn't this side stepping the problem?
3. If i could modify the Flat file using HTML and Javascript only. Why would i need JSP and Servlets? And if i could do it with JSP and Servlets only why would i need the think client ( HTML bit )?
If all of above 3 are correct ( conceptialy ), what is the orginal command line java program for?
The last question is why i think i have the concept wrong. Please i am new to web programming so feel free to point out any error.Hello,
You a little off on a few things. let me explain what each is used for to give you a better idea what each i used for.
HTML - Used to format data. Is static and can't do any File I/O and such
Javascript - Is usaually used for client side validation and some cool effects.
JSP - Is a scripting language that allows you to execute code on the server to create dynamic content and server side stuff like saving to a DB or a file
Servlets - Kinda like JSP but gives you more control over a few things. Usaually used for form processing and Servlet/Applet communication
for you application i would probably embed HTML/JavaScript for layout and validation into a JSP page for your display pages.. then build JSP pages to handle all you business logic and processing.
--Zer0C00L -
"Can you list me some features of the java language"(Interview question )
Hi,
This was a question I got yesterday in an interview, exactly as the interviewer said it.
I listed off it's cross platform feature... what else would you have added?
Question 2. He also looked for #2the differences between java and C++"It does if you put <sarcasm> tags in/Too easy, and that wasn't the point back then anyway. :)
Look at this forum sometime and see how many people
cram procedural code into a main and still call
themselves "Java programmers". Yepp. I dare to say that I do much better design, yet I don't call myself a programmer, even though I get paid for coding.
Java doesn't enforce
it, either. There's no way to mandate O-O thought.Yes and no. IIRC (it's been a very long time, and I mostly did C, anyway), you can write C++ code without ever creating one class. You can't do that in Java. So It's be a bad OOD, but never a good structural design, as structural design doesn't know classes. -
Hire a java expert for java proxy server.
hello,
i need a expert java programmer to hire for a simple java proxy project please contact me if you are intrested please leave me a message for more info.http://localhost:7021/sbresource?PROXY/MySample/MyJMSProxyService is the WSDL URL of the proxy.
Transport is is picked by the client from wsdl.
As far as the documentation of client generation is there, there is no change.
But meanwhile I have started working on sending the message directly to queue. JMSProxy is getting called. May be I will first run the proxy this way and then try troubleshooting the java client.
Regards
Ashwani -
Java.lang.ExceptionInInitializerError question
Hi, the following two postings were sent to the Programming forum, and we were referred to the Cryptography forum. Any ides on this problem, cryptography gurus?
This topic has 2 replies on 1 page (Most recent message: Jul 8, 2002 11:27 AM)
Having a problem with Java Cryptography Extension (JCE)
Author: dnhll23 Jul 6, 2002 2:11 AM
Hi, this is my first attempt at using the JCE. I'm using JCE 1.2.1
and basically all I'm trying to do at this point is encrypt a
FileInputStream object using the DES standard, with the JCE
classes. Here is my code Fragment.
protected FileOutputStream encriptFile(FileInputStream baseFile,
File encFileName) throws IOException
try
// Create the output file for the encrypted document
FileOutputStream encriptedFile = new FileOutputStream
(encFileName);
// Must register the provider that implements the algorithm
Provider sunJce = new com.sun.crypto.provider.SunJCE();
Security.addProvider(sunJce);
char[] pbeKeyData = password.toCharArray();
PBEKeySpec pbeKeySpec = new PBEKeySpec(pbeKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance
("DES");
SecretKey pbeKey = keyFactory.generateSecret(pbeKeySpec);
Cipher pbe = Cipher.getInstance("DES"); // Same as above.
pbe.init(Cipher.ENCRYPT_MODE, pbeKey);
CipherOutputStream cout = new CipherOutputStream
(encriptedFile, pbe);
// Use a byte array to write the file output in blocks of 64
bytes.
byte[] buffer = new byte[64];
while (true)
int bytesRead = -1;
bytesRead = baseFile.read(buffer);
if (bytesRead == -1) break;
cout.write(buffer, 0, bytesRead);
cout.flush();
cout.close();
baseFile.close(); // Close the input file.
catch (java.security.NoSuchAlgorithmException nsA)
System.err.println(nsA);
nsA.printStackTrace();
catch (java.lang.ExceptionInInitializerError eIIE)
System.err.println(eIIE);
eIIE.printStackTrace();
catch (Exception e)
System.err.println(e);
e.printStackTrace();
My problem arises with the line "SecretKeyFactory keyFactory =
SecretKeyFactory.getInstance("DES");" This line throws an
ExceptionInInitializerError and the catch block tells me this
java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError: java.lang.SecurityException:
Cannot set up certs for trusted CAs
(The rst of the stackCall here)...
From what I've read in the documentation, I need to have a provider
set up that handles the SecretKeyFactory and encryption algorithms,
but the documentation also says that the SunJCE provider that I set
up near the start of my method should have been able to handle this.
Is there anyone out there with expeience doing this kind of thing
that can help.
Thanks
Re: Having a problem with Java Cryptography Extension (JCE)
Author: mutmansky
In Reply To: Having a problem with Java Cryptography Extension (JCE) Jul 8, 2002 11:22 AM
Reply 1 of 2
Have you figured out an answer to this problem yet? I'm having a very similar problem. I'm running an applet that needs to decrypt information that it is retrieving from CORBA and I'm getting the following exception:
java.lang.ExceptionInInitializerError
at javax.crypto.Cipher.getInstance(DashoA6275)
at CorbaDecrypt.doDecryption(CorbaDecrypt.java:132)
at EventChannelListener.run(EventChannelListener.java:325)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs: java.lang.SecurityException: Cannot verify jar:file:C:/PROGRA~1/Java/J2RE14~1.0_0/lib/security/local_policy.jar!/
at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
... 3 more
I'm using JDK 1.4 so, there's no need for my code to have the two Provider setup lines, but otherwise my code looks much the same as yours. The code works fine when run in a test app on the server, but not in the Applet. The file that it's looking to verify (local_policy.jar) does not exist, and I don't want to create one manually, because my users would have to do that then too, which is unacceptable. I am using a trusted applet, so I'm not sure what more I can do to grant the applet the proper permissions. Does anyone have any ideas what we need to do here?
Thanks.
SteveHi all --
I'm have the same problem as the initially posted question. I'm using JDK 1.3.03 and I get the following excepion:
Exception in thread "main" java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.b.<clinit>([DashoPro-V1.2-120198])
at javax.crypto.SecretKeyFactory.getInstance([DashoPro-V1.2-120198])
at PasswordEncoder.encrypt(PasswordEncoder.java:28)
at PasswordEncoder.main(PasswordEncoder.java:89)
I've followed all the instructions for installation and configuration in the JCE User's Guide.
Any suggestions?
Thanks all.
Niran -
Java.util.logging question
'Lo all -
I'm new to Java, so bear with me on this question - I'm sure it has a simple answer.
I am using the following code to create a new Logger object:
public class TAGLogging {
private Logger oLog;
private FileHandler oLogFile;
private String sLoggingFolder = "AppLogs";
private String sFormattedDateTime = String.format("%1$tY%1$tm%1$td_%1$tH%1$tM%1$tS",Calendar.getInstance());
private String sCallingClass = new Throwable().fillInStackTrace().getStackTrace()[1].getClassName();
private String sCallingMethod = new Throwable().fillInStackTrace().getStackTrace()[1].getMethodName();
/** Constructors */
public TAGLogging(String sLogFileName) throws IOException {
this.initialSetup(sLogFileName);
public TAGLogging() throws IOException {
String sLogFileName = sLoggingFolder + File.separator + sFormattedDateTime + ".xml";
this.initialSetup(sLogFileName);
/** Methods */
private void initialSetup(String logFileName) throws IOException {
oLogFile = new FileHandler(logFileName);
oLog = Logger.getLogger(sCallingClass);
oLog.addHandler(oLogFile);
oLog.setLevel(Level.ALL);
}Everything is being logged correctly to the /AppLogs/yyyymmdd_HHMMSS.xml file. The problem is that there is another file that is being created in my home directory, which incidentally, is not where the program is located. The name, java01.log, matches the default logging.properties file set up, but I have removed all that and changed the file to the following (minus all the comments):
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.level = ALL
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
The java01.log file contains the exact same contents as the file I am purposely logging to, the AppLogs/yyyymmd_HHMMSS.xml one.
Does anyone have any clue what is causing this file to get created, and if so, how do I stop it?
Message was edited by:
malakhMan, I REALLY hate to do this, but it looks like I may be forced to work around it instead of fixing the issue. I'll have to add some code to manually remove the java01.log file when it's done writing to it.
Navy - Turns out that Log4j is pretty much the same thing as java.util.logging, except on steroids. It is almost identical syntactically, just has more options and more flexibility than JUL. -
Four Java Applet signing questions
hi all;
I'd like to ask a few quick questions about applet signing. As you know there is a "Security Warning" Gray Alert box that appears when the user tries to load your signed applet.
1. When the alert window asks someone to accept the signed applet, is it possible to some how capture the Yes or No button click event by javascript or something like that ? I noticed that the Yes and No Response seems to be saved in an in-memory cookie? Is it possible to figure out wht the person clicked ?
2. Is it possible to keep that "Security Warning" Alert box on top so that the user will not be able to accidentally ignore it (it goes under the browser and stays there).
3. Is there some way to inspect the PC to determine weather your applet loaded properly - apart from seeing a properly working applet ? For example , If I want to make sure it is being cached properly.
4. When a new version of the applet is available on the server ? how does the browser know to download something ? is that something I would code for manually or would is this automatically handled behind the scenes.
Thanks in advance
StephenI can only reply to nr 1 but looking at java.security.AccessControl there is a method called checkPermission() you can use.
Maybe you are looking for
-
Development and marketing of SAP EP solutions - any licenses required?
Hi Not sure which forum to post this in, so - maybe Coffee Corner is a good start My question is about the licensing required to development and marketing small add-ons / extensions for SAP Enterprise Portal. Is it possible for the individual develop
-
In tears... please help
;( PLEASE PLEASE Help me. I've just built the following system: MSI KT3 Ultra ARU Motherboard Western Dig 80GB 5400 speed Hard drive Liteon DVD Teac CDRW (40/48/12) Gainward graphics card SB Audigy Player 256MB Ram AMD Athlon 1900+ XP Modem Win XP I
-
Displaying Master-Data using ADF DI
Hi I'm trying to display a master data(as a form) and a detail data(as a table) in excel sheet using ADF DI. The process I followed is as below. 1. This is on HR schema. I created a departmentsVO, and dragged Departments from the data control to the
-
How do I get rid of this malware? Please help...
At least I think it's malware. I realized last night that there were an awful amount of ads, pop-up windows, and warnings coming from my normally visited sites. This only happens on Google Chrome (does not happen on Firefox and Safari) So I ran Sopho
-
I made a mistake marking the the previous topic with the same name as solved!!! Problem still not solved! Hello, I have the following problem. Charasteristic has text.Data to infocube was uploaded later than text and master data for charasteristic. M