Setting classpath during Runtime
hi,
here's what i want to archive:
i have a directory (not! the starting dir) containing classes
the location of that directory i don't know until runtime
the classes have to be accessible by the Class.forName("class").newInstance(); method
no, i can not write a classloader instead of the forName() <- this is fix
i tried with System.setProperty("java.class.path", newclasspath);
and with a classloader, that loads the classes, before the forName() method is invoked (i hoped forName() would find already loaded classes)
didn't work
i'm deeply thankful for every hint
It's not exactly Pure Java (not at all, really).. But
couldn't you do a:
String myOldClasspath,myNewClasspath;
myOldClasspath =
System.getProperty("java.class.path");
Runtime.getRuntime().exec("SET
CLASSPATH="+myNewClasspath);
// Perform Operations
Runtime.getRuntime().exec("SET
CLASSPATH="+myOldClasspath);Probably not.
First 'set' is a shell command so the program wouldn't run at all. You would need to provide a shell.
Second anytime you use exec() it starts another process space. Anything that happens to the environment in that process only affects that process. So this solution would only work if it was acceptable to have two running java applications. The first sets up the environment and the second does the real work.
Similar Messages
-
How can we set classpath to a .jar file during runtime. Is it possible to set classpath not other than editing a .bat file or by manually editing the global variables list????
You need to implement you own Class Loader if you want to load a jar at runtime. Why would you like to do that in AS?
-
Hi everybody! I'm using NetBeans IDE 3.6 and I want to change the classpath at runtime. I�ve tried to make:
set classpath="C:\Documents and Settings\Koening\Mis documentos\Proyectos";but it doesn�t recognize that sentence. If anybody knows how to change it at runtime please answer me.
Thanks for the replies!!!I assume you were talking about a .bat file as you're writing that more or less in .bat format. The main problem if that's the case, is that you're not supposed to put quotes around the value:
set classpath=C:\Documents and Settings\Koening\Mis documentos\Proyectos
Actually changing the classpath at "runtime" (i.e., after the JVM is started) is more involved, and normally requires writing a launcher class which does nothing but create a URLClassLoader with the appropriate URLs, fetch the real main class from the new classloader, and executes its main method. -
Classpath during runtime.
Is there any way to check the classpath for the JVM at runtime ?
The reason for doing this is that I got an exception, that the JVM can't find a specific class, even though I can do a class.forName on the class when starting up the application.
Later it suddenly can't find the same class...
Regards
/AndreasIf you have a exception in the contructor of a class,
i may be removed from the class loader.
Use try catch block in the contructor if required.
. (Compiler may not inform you about it, since you
may have runtime exception at the contructor.)No. It will not remove the class from the classloader due to an exception in an instance constructor/initializer. See my reply #1. -
Can I Determine classpath during Runtime?
If I start java with "java -classpath build;etc;myDir se.company.Main" how can I -- from my java code -- check what JAR files and/or directories are part of the classpath??
System.getProperty("java.class.path")
-
How to set borderColor from css during runtime
Hi,
I need to set the border color of a selected tab during runtime from css. Is it possible. Please help i am struggling with this for past two days.
regards,
Jayagopal.Just create a selected CSS style, and update the styleName of the tab when it is selected.
-
How to set a line of table as read only during runtime?
How to set a line (or a cell) of table as read only during runtime?
hi wei
when you create a table keep the readonly property of table as false
you create the columns of table as inputfield.you bind the readonly property of
the inputfield to two context variables
say one for all the columnfields you to want always have as readonly and let this contextattribute of type boolean and let this be attr1
and another for all the columnfields you donot want to be readonly and let this contextattribute of type boolean and let this be attr2
initially set the context attributes attr1 and attr2 as true so the entire table is readonly.
based on the condition you want to check change the attr2 to be false.
if(your condition)
wdcontext.currentcontextelement.setattr2(false);
hope this helps.
regards
saravana -
How do I set the classpath in runtime?
How can i set the classpath in runtime?
Im downloading my image files in the folder C:/Downloads
I want to set this C:/Downloads as my classpath.
I don want to set it at the initial stage, bcoz I may have to change the downloading directory D:/Selva.
I want to access my */utils/New.gif* image available in the downloading directory by using getResource() method.java.net.URL urldir= new java.net.URL("file://C:/Downloads/");
java.net.URL[] urlarr= new java.net.URL[1];
urlarr[0]=urldir;
java.net.URLClassLoader urlcl= new java.net.URLClassLoader(urlarr); +// Here I get the Error+
url=urlcl.getResource("/lrp/utils/New.gif");
*Error: java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader+ -
Setting canvas property of item during runtime
Can anybody tell me how to set the canvas property of item in the block at runtime if the canvas property is set to null during runtime.
Pls forward the answer.
Thanks.Frank,
Alternatively , you can create mirror item and place them on different canvases, further you can hide/show them.
Thanks.
Adinath Kamode -
JMF set video source to S-video/Tuner/Composite during runtime
Does anyone know how to change Video Source from Video Tuner to Video Composite or S-Video?
I'm using LifeView card. I can get them to work manually. However, I have no clue how to set them at runtime. I want to have buttons to swith from Tuner to Composite to S-Video at will.
10 dukees to anyone who answers it!
Thanks,
HirenIf your code was an SSCCE*, I could run it
against some images that I have successfully
used to create MOV's (using my own variant of
JPEGImagesToMovie).
It isn't, so I can't.
The only thing I can suggest (off the top of
my head) is that the images need to be all
the same size/width, and the same as
specified for the MOV, otherwise a corrupted
MOV will be written.
* http://www.physci.org/codes/sscce/ -
A question about how to change a button in a JPanel during runtime
I am a beginner of GUI. Now I am trying to change a specific component, a button, when the application is running. For example, I have 3 buttons in a JPanel. Each button has its onw icon. If I click one of them, it will change its icon, but the other two don't change. I don't know if there is any method for changing a specific component during runtime. If any one knows please let me know, I will appreciate that very much!!!
What you're going to have to do is loop inside the actionlistener but still have accessability to click while its looping. I don't know much about it, but I think you're going to need a thread. Try something like this... (it doesn't work yet, but I have to take off)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class buttonxdemo extends JFrame implements ActionListener{
Buttonx mybutton;
//set it all up, make it look pretty =]
public buttonxdemo()
mybutton = new Buttonx("default");
getContentPane().add(mybutton.thebutton);
mybutton.thebutton.addActionListener(this);
this.setDefaultCloseOperation(3);
this.setSize(200,200);
public void actionPerformed(ActionEvent ae){
if (ae.getSource() == mybutton.thebutton)
if (mybutton.keepGoing)
mybutton.keepGoing = false;
else if (!mybutton.keepGoing)
mybutton.keepGoing = true;
mybutton = new Buttonx(/*Icon,*/"My Button");
//getContentPane().remove(mybutton);
//getContentPane().add(mybutton.thebutton);
mybutton.startstop();
}//actionperformed
static void main(String args[])
new buttonxdemo().show();
} //movingicondemo
class Buttonx extends Thread{
public boolean keepGoing;
//public Icon ICx; //perhaps an array, so you can loop through?
public String strbuttonx;
public JButton thebutton; //may have to extend JFrame?
public Buttonx(/*Icon IC,*/ String strbutton){
//ICx = IC;
strbuttonx = strbutton;
thebutton = new JButton(strbuttonx);
public void startstop()
int i = 0;
while (keepGoing)
thebutton.setLabel(strbuttonx.substring(0,i));
//if an array of Icons ICx
//thebutton.setIcon(ICx);
i++;
if (i > strbuttonx.length() - 1)
i = 0;
try
Thread.sleep(1000);
catch (InterruptedException ie)
System.out.println("sleep caught: " + ie);
}//startstop()
}//buttonx
kev -
I'm very new to LabVIEW and every day I learn such a lot about LabVIEW. I did not find any example according to my problem, but I don't know how to do the following :
In the MainVI I read different strings from file in an array (In the example below I defined them as constants. The example only shows how the frontpanels should look like).
During a loop I calculate different values, which will be written in an array, too, and in every loop the array of values will be overwritten with the new calculated values. (string[i] belongs to value[i])
Now, by pushing the button 'sub' during runtime, I want to op
en the Frontpanel of a SubVI, on which you see a Ring and a numeric Indicator. Now, I want to show the strings I read in the MainVI as items in the Ring-menu. If I choose one of the items (strings) in the Ring-menu during runtime, I want to show the accordant value, which was calculated in the MainVI, in the numeric Indicator, and in every loop the new calculated value should be shown in this Indicator automatically.
So I have two questions:
1. How do I put the strings into the Ring-menu during runtime?
2. How to open a SubVI-Frontpanel during runtime, and how to pass the calculated values to it?
Every answer I accept with thanks!
Attachments:
main.vi 29 KB
sub.vi 9 KBSee the atttached vis :
1/ Pass the string array to the sub-vi, then use a property node to replace the ring node strings
2a/ From the subvi front panel window, rightclick on the icon, and select "Show connector". Define the connections
2b/Set the sub vi properties (right click on the vi icon, select "VI properties... >> Window appearance..." go to "customize...", and checkmark the "Show front panel when called" item).
3/ your main vi should run 2 separate loops in order to avoid that reading the data stops the aquisition process (if any !..), or the reverse situation.
You should read the LV manual to find out how to create a sub-vi : there are a number a basic things to learn and to memorize...
CC
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Attachments:
main.vi.zip 16 KB -
Object Referenced Error When calling the Windows Form during Runtime
Hi,
I am getting Object reference errors when running windows form during runtime. In debugging mode in MS Visual studio 2005, I am not getting this error. I'm calling the window form from menu and called the window in a thread as suggested in one of forums . I don't see anyone in the forum mentioned this problem I have. Any help would be deeply appreciated. Below are the error and code samples.
ERROR Message
Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Project1.Loadxml.Loadxml_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Edited by: Albert Tio on Feb 16, 2011 9:55 AMHere is the code.
Option Strict Off
Option Explicit On
Friend Class GetEvents
Public WithEvents SBO_Application As SAPbouiCOM.Application
Public SboGuiApi As SAPbouiCOM.SboGuiApi
Public oForm As SAPbouiCOM.Form
Public oDBDataSource As SAPbouiCOM.DBDataSource
Public oCompany As SAPbobsCOM.Company
Public RS As SAPbobsCOM.Recordset
Public oPrev_Bank As String, oPrev_AcctType As String
Public oLoadXml As Loadxml
Public Sub SetApplication()
'Dim SboGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
SboGuiApi = New SAPbouiCOM.SboGuiApi
' by following the steps specified above, the following
' statment should be suficient for either development or run mode
sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
' connect to a running SBO Application
SboGuiApi.Connect(sConnectionString)
' get an initialized application object
SBO_Application = SboGuiApi.GetApplication()
End Sub
Public Sub SetCompany()
Dim ret As Long
Dim MsgStr As String
Dim Cookie As String
Dim ConnStr As String
Try
oCompany = New SAPbobsCOM.Company
Cookie = oCompany.GetContextCookie
ConnStr = SBO_Application.Company.GetConnectionContext(Cookie)
'//before setting the SBO login context make sure the company is not connected
If oCompany.Connected = True Then
oCompany.Disconnect()
End If
ret = oCompany.SetSboLoginContext(ConnStr)
If Not ret = 0 Then
Exit Sub
End If
ret = oCompany.Connect
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
End Try
MsgStr = ""
If Not ret = 0 Then
oCompany.GetLastError(ret, MsgStr)
SBO_Application.MessageBox(MsgStr)
Else
End If
End Sub
Public Sub New()
MyBase.New()
' set SBO_Application with an initialized application object
SetApplication()
SetCompany()
AddMenuItems()
End Sub
Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
Dim myThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf LoadXmlMainThread))
Try
If (pVal.MenuUID = "MySubMenu") And (pVal.BeforeAction = False) Then
'SBO_Application.MessageBox("My sub menu item was clicked")
'// Create a form to be launched in response to a click on the
'// new sub menu item
myThread.SetApartmentState(System.Threading.ApartmentState.STA)
myThread.Start()
'Loadxml.ShowDialog()
End If
Catch ex As Exception
SBO_Application.MessageBox("1." & ex.Message)
End Try
'If (pVal.MenuUID = "MyGoToMenu") And (pVal.BeforeAction = False) Then
' SBO_Application.MessageBox("My GoTo Menu was clicked")
'End If
'If (pVal.MenuUID = "MySecondGoToMenu") And (pVal.BeforeAction = False) Then
' SBO_Application.MessageBox("My Second GoTo Menu was clicked")
'End If
End Sub
Private Sub LoadXmlMainThread()
'Dim lLoadxml As New Loadxml
Try
oLoadXml = New Loadxml
oLoadXml.WindowState = FormWindowState.Maximized
oLoadXml.ShowInTaskbar = True
oLoadXml.TopMost = True
oLoadXml.Activate()
Application.Run(oLoadXml)
Catch ex As Exception
SBO_Application.MessageBox("2." & ex.Message)
End Try
End Sub
Private Sub AddMenuItems()
'// Let's add a separator, a pop-up menu item and a string menu item
Dim oMenus As SAPbouiCOM.Menus
Dim oMenuItem As SAPbouiCOM.MenuItem
Dim i As Integer '// to be used as counter
Dim lAddAfter As Integer
Dim sXML As String
'// Get the menus collection from the application
oMenus = SBO_Application.Menus
'Save an XML file containing the menus...
'sXML = SBO_Application.Menus.GetAsXML
'Dim xmlD As System.Xml.XmlDocument
'xmlD = New System.Xml.XmlDocument
'xmlD.LoadXml(sXML)
'xmlD.Save("c:
mnu.xml")
Dim oCreationPackage As SAPbouiCOM.MenuCreationParams
oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)
oMenuItem = SBO_Application.Menus.Item("43520") 'moudles'
Dim sPath As String
sPath = Application.StartupPath
'sPath = sPath.Remove(sPath.Length - 3, 3)
If sPath.EndsWith("\") = False Then
sPath = sPath & "\"
End If
'// find the place in wich you want to add your menu item
'// in this example I chose to add my menu item under
'// SAP Business One.
oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP
oCreationPackage.UniqueID = "MyMenu01"
oCreationPackage.String = "Unbridle Menu"
oCreationPackage.Enabled = True
oCreationPackage.Image = sPath & "unbridle.bmp"
oCreationPackage.Position = 15
oMenus = oMenuItem.SubMenus
Try ' If the manu already exists this code will fail
oMenus.AddEx(oCreationPackage)
'// Get the menu collection of the newly added pop-up item
oMenuItem = SBO_Application.Menus.Item("MyMenu01")
oMenus = oMenuItem.SubMenus
'// Create s sub menu
oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING
oCreationPackage.UniqueID = "MySubMenu"
oCreationPackage.String = "Unbridle Monitoring"
oMenus.AddEx(oCreationPackage)
Catch er As Exception ' Menu already exists
'SBO_Application.MessageBox("Menu Already Exists")
End Try
End Sub
End Class
Public Class Loadxml
'Inherits System.Windows.Forms.Form
Public sBPpath As String
Public sGLpath As String
Public sBillpath As String
Public bRun As Boolean
Private Sub Loadxml_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextGL.Text = System.Configuration.ConfigurationSettings.AppSettings("GLAcctDownloadPath").ToString()
Me.TextBP.Text = System.Configuration.ConfigurationSettings.AppSettings("BPAcctUPloadPath").ToString()
Me.TextBill.Text = System.Configuration.ConfigurationSettings.AppSettings("BillUPloadPath").ToString()
Me.NotifyIcon1.Visible = False
End Sub
End Class -
Receiver SOAP - How to set URL at runtime?
I have configured a Receiver SOAP adapter for sending a cXML message to a vendor in no-soap, keep-headers mode. If I want to extend this to other vendors, I want to set the target URL at runtime. In order to do this, I am able to set the TServerLocation in the Mapping. But in the communication channel, I am not able to select this indicator. I am able to select the 'Use Adapter specific message attributes' and 'Variable Transport Binding' indicators but thats it. I am not displayed any form for selecting the target URL as the field to substitute during runtime. I am using SAP Basis 7.00 for the Adapter Metadata. Does anybody know a work around or patch I need?
Hello James,
I don't know whether this question is still open, but I have faced the same problem now, so here is my solution:
It is right, that the "Target URL" field has to be filled with some "dummy" value to be able to save+activate the communication channel.
In any other communication channels (e.g. like file adapter) you can fill in the <dummy> value. But at the SOAP receiver it doesn't work.
Instead of <dummy>, if you fill in a real URL address, it will always take it instead of the dynamic one.
My solution is, to fill in only the "http://" value, and it will take your dynamic URL from your UDF. (from the variable TServerLocation)
I hope it helps!
Best regards,
Andras -
Is it possible to add/change a ViewContainerUIElement during runtime?
Hi all,
i want to add/change the content of a ViewContainerUIElement (VCUI) during runtime, but it doesn't work as expected (or hoped;). What i got working so far for an <b>already exising</b> VCUI is:
1. Find the IWDViewContainerInfo for the VCUI
2. If no default view usage exists, create an embedded view usage and set is as default.
3. Set the component usage to the IWDComponentUsageInfo requested.
4. Set the view to the IWDViewUsageInfo of the interface view, which should be the content of the VCUI.
This doesn't work, if it's done after the wdDoInit()s of the controller hierarchy has been processed. The component, which is represented by the usage, is deleted and recreated, but the visual representation doesn't get updated (e.g. no changes on the display) if it's done in an action handler for example. Why? If i change the component usage (cloned component usage) nothing happens too.
Even more problems arise, if i try to add a new VCUI. The steps are pretty the same as before, what is done additionally (and prior the steps above) is:
1. Creating a IWDViewContainerInfo from the IWDViewInfo of the "parent" view.
2. Creating a IWDViewContainerAssignmentInfo from the view usage of the "parent" view
3. Setting the created IWDViewContainerInfo as view container in the assignment.
4. Create the VCUI, set the view container name to the name of the created IWDViewContainerInfo and add the VCUI to an arbitrary container in the parent view.
But this doesn't work, i'm getting:
java.lang.NullPointerException
at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.ViewContainerUIElementAdapter.getContent(ViewContainerUIElementAdapter.java:98)
What is wrong? What am i missing?
Thanks in advance.
StefanHi,
I had the same problem with
"java.lang.NullPointerException at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.ViewContainerUIElementAdapter.getContent(ViewContainerUIElementAdapter.java:98)"
when I included ViewUsages dynamically in an action handler (outside wdDoInit()).
The code below fixed that problem.
This code creates a new OutboundPlug for the embedding view with the embedded view as target and fires the plug.
<i>// Create OutboundPlug
IWDOutboundPlugInfo outboundPlug = embedderViewInfo.createOutboundPlug();
//Create navigation link
rootViewUsage.createNavigationTarget(outboundPlug.getName(), interfaceViewUsage, "Default");
// fire navigation link
wdThis.wdGetAPI().firePlug(outboundPlug, Collections.EMPTY_MAP);
</i>
I hope I could help you. Probably you don't need the information anymore, but perhaps anybody else has the same problem.
Regards, Alex
Maybe you are looking for
-
I'm new to this, so please be patient. I want to edit photos in RAW format. I use a Leica D-Lux 4 camera and always save in RAW (these upload as .rwl files). How do I get these into PS Elements to work on them? I'm a MAC user. When in PS Elements
-
Delete an Entry, Selected in a WebDynpro Table
Hello Everybody, i'm doing my first exercises programming in WebDynpro Abap and stuck at the following point: I implemented a database-table containing customer data, created a function module which returns all entries, and a webdynpro view which dis
-
How do I get rid of IOS7 app icons?
The new IOS7 update icons look like toy apps. They look very unprofessional and hard to figure out. What happened to Apple being for educational and business applications and a reliable computer and software company? Like to know how to change back t
-
When I go to transfer my library from my old netbook running XP to my new one running Windows 7, I get a message after all the library is transfered saying 'autorisation is need to access...' on all the transfered files. I managed to successfully tra
-
YF:CA_SC_GEN-TESTER security role
I have been using YF:CA_SC_GEN-TESTER in the dev environment successfully uptill now. In production we cannot use the same role. I need to create Business Partner, create catalogs, etc. Can someone help me in providing a role which gives this authori